There should be no user error if incoming shipment is not in done state.

In fact, that is correct. Even more, the message must be shown when there's no
incoming shipment only and in the assign_try button.
(grafted from d7fb4754552332ed9784fac21df98b2d977d2e45)
This commit is contained in:
Albert Cervera i Areny 2016-08-03 15:51:32 +02:00
parent f49456ecda
commit 0637b9e039
3 changed files with 19 additions and 32 deletions

View File

@ -1,14 +1,10 @@
#
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "error:production:"
msgid "The production \"%s\" has no incoming shipment."
msgstr "La producció \"%s\" no té l'albarà d'entrada."
msgctxt "error:production:"
msgid "The production \"%s\" has no the incoming shipment \"%s\" as done."
msgstr "La producció \"%s\" no té l'albarà d'entrada \"%s\" en estat realitzat."
msgid "The party \"%s\" has no production location."
msgstr "El tercer \"%s\" no té ubicació de producció."
msgctxt "error:production:"
msgid "The warehouse \"%s\" has no production location."

View File

@ -1,16 +1,10 @@
#
#
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "error:production:"
msgid "The production \"%s\" has no incoming shipment."
msgstr "La producción \"%s\" no tiene el albarán de entrada."
msgctxt "error:production:"
msgid "The production \"%s\" has no the incoming shipment \"%s\" as done."
msgid "The party \"%s\" has no production location."
msgstr ""
"La producción \"%s\" no tiene el albarán de entrada \"%s\" en estado "
"realizado."
msgctxt "error:production:"
msgid "The warehouse \"%s\" has no production location."

View File

@ -1,7 +1,7 @@
# The COPYRIGHT file at the top level of this repository contains the full
# copyright notices and license terms.
from trytond.pool import Pool, PoolMeta
from trytond.model import ModelView, fields
from trytond.model import Workflow, ModelView, fields
from trytond.pyson import Eval, Bool
__all__ = ['Party', 'PurchaseRequest', 'BOM', 'Production', 'Purchase']
@ -67,8 +67,6 @@ class Production:
@classmethod
def __setup__(cls):
super(Production, cls).__setup__()
# TODO: Do not allow starting a production if purchase_request has been
# created but purchase order is not in processing state.
cls._buttons.update({
'create_purchase_request': {
'invisible': ~(Eval('state').in_(['draft', 'waiting']) &
@ -78,14 +76,13 @@ class Production:
}
})
cls._error_messages.update({
'no_subcontract_warehouse': 'The party "%s" has no production '
'location.',
'no_warehouse_production_location': 'The warehouse "%s" has '
'no production location.',
'no_incoming_shipment': 'The production "%s" has no incoming '
'shipment.',
'no_incoming_shipment_done': ('The production "%s" has no the '
'incoming shipment "%s" as done.'),
'no_subcontract_warehouse': ('The party "%s" has no production '
'location.'),
'no_warehouse_production_location': ('The warehouse "%s" has '
'no production location.'),
'no_incoming_shipment': ('The production "%s" has no incoming '
'shipment. You must process the purchase before the '
'production can be assigned.'),
})
def get_supplier(self, name):
@ -232,19 +229,19 @@ class Production:
pass
@classmethod
def run(cls, productions):
@ModelView.button
#@Workflow.transition('assigned')
def assign_try(cls, productions):
for p in productions:
if p.purchase_request:
if not p.incoming_shipment:
cls.raise_user_error('no_incoming_shipment', (
p.code,))
if not p.incoming_shipment.state == 'done':
cls.raise_user_error('no_incoming_shipment_done', (
p.code, p.incoming_shipment.rec_name,))
super(Production, cls).run(productions)
return super(Production, cls).assign_try(productions)
@classmethod
@ModelView.button
@Workflow.transition('done')
def done(cls, productions):
InternalShipment = Pool().get('stock.shipment.internal')
super(Production, cls).done(productions)