Cédric Krier pushed to branch branch/default at Tryton / Tryton


Commits:
e22f31a0 by Cédric Krier at 2022-12-29T18:19:37+01:00
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
- - - - -


2 changed files:

- modules/sale_supply/sale.py
- modules/sale_supply/stock.py


Changes:

=====================================
modules/sale_supply/sale.py
=====================================
@@ -221,9 +221,14 @@
 
         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 = []


=====================================
modules/sale_supply/stock.py
=====================================
@@ -47,7 +47,11 @@
                 ('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(



View it on Heptapod: 
https://foss.heptapod.net/tryton/tryton/-/commit/e22f31a0163998902145ea47d76ded437e0c7ccf

-- 
View it on Heptapod: 
https://foss.heptapod.net/tryton/tryton/-/commit/e22f31a0163998902145ea47d76ded437e0c7ccf
You're receiving this email because of your account on foss.heptapod.net.


Reply via email to