changeset 2493c4c10716 in modules/stock:default
details: https://hg.tryton.org/modules/stock?cmd=changeset;node=2493c4c10716
description:
Manage staging moves on shipment workflow
Staging moves are automatically assigned when purchased so
we should remove them when packing a shipment as they are
not part of the shipment.
We also skip moves with zero quantity because they will
always succeed.
issue9448
review313951002
diffstat:
move.py | 6 ++++--
shipment.py | 6 ++++++
2 files changed, 10 insertions(+), 2 deletions(-)
diffs (41 lines):
diff -r 421eff5b8e3b -r 2493c4c10716 move.py
--- a/move.py Sat Mar 06 19:07:48 2021 +0100
+++ b/move.py Sat Mar 06 19:19:53 2021 +0100
@@ -474,10 +474,12 @@
return ((from_type != 'storage' and to_type == 'storage')
or (from_type == 'storage' and to_type != 'storage'))
- @fields.depends('from_location')
+ @fields.depends('from_location', 'quantity')
def on_change_with_assignation_required(self, name=None):
if self.from_location:
- return self.from_location.type in {'storage', 'view'}
+ return (
+ self.quantity
+ and self.from_location.type in {'storage', 'view'})
@staticmethod
def _get_shipment():
diff -r 421eff5b8e3b -r 2493c4c10716 shipment.py
--- a/shipment.py Sat Mar 06 19:07:48 2021 +0100
+++ b/shipment.py Sat Mar 06 19:19:53 2021 +0100
@@ -1249,6 +1249,9 @@
def pick(cls, shipments):
pool = Pool()
Move = pool.get('stock.move')
+ Move.delete([
+ m for s in shipments for m in s.inventory_moves
+ if m.state == 'staging'])
Move.do([m for s in shipments for m in s.inventory_moves])
cls._sync_inventory_to_outgoing(shipments, quantity=True)
@@ -1350,6 +1353,9 @@
Move = pool.get('stock.move')
Date = pool.get('ir.date')
+ Move.delete([
+ m for s in shipments for m in s.outgoing_moves
+ if m.state == 'staging'])
Move.do([m for s in shipments for m in s.outgoing_moves])
cls.write([s for s in shipments if not s.effective_date], {
'effective_date': Date.today(),