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


Commits:
ce0b073c by Cédric Krier at 2023-04-13T17:45:09+02:00
Use fixed location type to compute quantity to invoice for sale and purchase

Using the computed location to get the expected type is not reliable because
for return order, the location can be of different type and the stock move can
change of location type.

Closes #12203
- - - - -


2 changed files:

- modules/purchase/purchase.py
- modules/sale/sale.py


Changes:

=====================================
modules/purchase/purchase.py
=====================================
@@ -1735,10 +1735,10 @@
                 qty = Uom.compute_qty(move.uom, move.quantity, self.unit)
                 # Test only against from_location
                 # as it is what matters for purchase
-                src_type = self.from_location.type
+                src_type = 'supplier'
                 if (move.from_location.type == src_type
                         and move.to_location.type != src_type):
                     quantity += qty
                 elif (move.to_location.type == src_type
                         and move.from_location.type != src_type):
                     quantity -= qty
@@ -1739,11 +1739,9 @@
                 if (move.from_location.type == src_type
                         and move.to_location.type != src_type):
                     quantity += qty
                 elif (move.to_location.type == src_type
                         and move.from_location.type != src_type):
                     quantity -= qty
-            if self.quantity < 0:
-                quantity *= -1
             return quantity
 
     def _get_invoiced_quantity(self):


=====================================
modules/sale/sale.py
=====================================
@@ -1729,10 +1729,10 @@
                 qty = Uom.compute_qty(move.uom, move.quantity, self.unit)
                 # Test only against to_location
                 # as it is what matters for sale
-                dest_type = self.to_location.type
+                dest_type = 'customer'
                 if (move.to_location.type == dest_type
                         and move.from_location.type != dest_type):
                     quantity += qty
                 elif (move.from_location.type == dest_type
                         and move.to_location.type != dest_type):
                     quantity -= qty
@@ -1733,11 +1733,9 @@
                 if (move.to_location.type == dest_type
                         and move.from_location.type != dest_type):
                     quantity += qty
                 elif (move.from_location.type == dest_type
                         and move.to_location.type != dest_type):
                     quantity -= qty
-            if self.quantity < 0:
-                quantity *= -1
             return quantity
 
     def _get_invoiced_quantity(self):



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

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


Reply via email to