changeset 9119f03fb1cc in modules/stock:default
details: https://hg.tryton.org/modules/stock?cmd=changeset&node=9119f03fb1cc
description:
        Ensure inventory moves are done before packing

        issue10620
        review363611002
diffstat:

 message.xml |  3 +++
 shipment.py |  6 ++++++
 2 files changed, 9 insertions(+), 0 deletions(-)

diffs (29 lines):

diff -r 7695afdfb9ce -r 9119f03fb1cc message.xml
--- a/message.xml       Thu Aug 12 18:45:25 2021 +0200
+++ b/message.xml       Thu Aug 12 18:46:18 2021 +0200
@@ -32,6 +32,9 @@
         <record model="ir.message" id="msg_period_close_assigned_move">
             <field name="text">You cannot close periods with assigned moves in 
it.</field>
         </record>
+        <record model="ir.message" id="msg_shipment_pack_inventory_done">
+            <field name="text">To pack shipment "%(shipment)s" you must do the 
inventory moves.</field>
+        </record>
         <record model="ir.message" id="msg_shipment_delete_cancel">
             <field name="text">To delete shipment "%(shipment)s" you must 
cancel it.</field>
         </record>
diff -r 7695afdfb9ce -r 9119f03fb1cc shipment.py
--- a/shipment.py       Thu Aug 12 18:45:25 2021 +0200
+++ b/shipment.py       Thu Aug 12 18:46:18 2021 +0200
@@ -1333,6 +1333,12 @@
     def pack(cls, shipments):
         pool = Pool()
         Move = pool.get('stock.move')
+        for shipment in shipments:
+            for move in shipment.inventory_moves:
+                if move.state != 'done':
+                    raise AccessError(
+                        gettext('stock.msg_shipment_pack_inventory_done',
+                            shipment=shipment.rec_name))
         Move.delete([m for s in shipments for m in s.outgoing_moves
             if not m.quantity])
         Move.assign([m for s in shipments for m in s.outgoing_moves])

Reply via email to