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
This commit is contained in:
Sergi Almacellas Abellana
2021-03-06 19:19:53 +01:00
parent 9e6e245f02
commit ceefdeb72f
2 changed files with 10 additions and 2 deletions
+4 -2
View File
@@ -474,10 +474,12 @@ class Move(Workflow, ModelSQL, ModelView):
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():
+6
View File
@@ -1249,6 +1249,9 @@ class ShipmentOut(ShipmentAssignMixin, Workflow, ModelSQL, ModelView):
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 @@ class ShipmentOut(ShipmentAssignMixin, Workflow, ModelSQL, ModelView):
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(),