Assign supplied outgoing moves instead of inventory moves

If the output location is the same as the storage location, there is no
inventory moves on the outgoing shipment, so the outgoing moves must be
assigned.
If the input location is the same as the storage location, there is neither
inventory moves on the incoming shipment, so the quantity must be computed
based on the incoming moves.

Closes #11972
(grafted from e22f31a0163998902145ea47d76ded437e0c7ccf)

--HG--
branch : 6.0
This commit is contained in:
Cédric Krier
2022-12-29 18:19:37 +01:00
parent 393aff1f07
commit ceed27e09c
2 changed files with 13 additions and 4 deletions
+8 -3
View File
@@ -212,9 +212,14 @@ class Line(metaclass=PoolMeta):
moves = set()
for move in self.moves:
if isinstance(move.shipment, ShipmentOut):
for inv_move in move.shipment.inventory_moves:
if inv_move.product.id == self.product.id:
shipment = move.shipment
if isinstance(shipment, ShipmentOut):
if shipment.warehouse_storage == shipment.warehouse_output:
inventory_moves = shipment.outgoing_moves
else:
inventory_moves = shipment.inventory_moves
for inv_move in inventory_moves:
if inv_move.product == self.product:
moves.add(inv_move)
to_write = []
to_assign = []
+5 -1
View File
@@ -47,7 +47,11 @@ class ShipmentIn(metaclass=PoolMeta):
('purchase_request.origin', 'like', 'sale.sale,%'),
])
pbl = defaultdict(lambda: defaultdict(int))
for move in filter(filter_func, self.inventory_moves):
if self.warehouse_storage == self.warehouse_input:
inventory_moves = self.incoming_moves
else:
inventory_moves = self.inventory_moves
for move in filter(filter_func, inventory_moves):
pbl[move.product][get_key(move)] += move.internal_quantity
for sale_line in sale_lines:
sale_line.assign_supplied(