From cce1a6658fb80babbf7be50160dd37c4915845b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Thu, 13 Apr 2023 17:45:09 +0200 Subject: [PATCH] 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 (grafted from ce0b073cd8e637b8052ae3fa5e9bb4d8a7f6ea53) --HG-- branch : 6.0 --- modules/purchase/purchase.py | 4 +--- modules/sale/sale.py | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/modules/purchase/purchase.py b/modules/purchase/purchase.py index 82263c2393..7d14103616 100644 --- a/modules/purchase/purchase.py +++ b/modules/purchase/purchase.py @@ -1594,15 +1594,13 @@ class Line(sequence_ordered(), ModelSQL, ModelView): 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 - if self.quantity < 0: - quantity *= -1 return quantity def _get_invoiced_quantity(self): diff --git a/modules/sale/sale.py b/modules/sale/sale.py index cdf8c0160a..330312c007 100644 --- a/modules/sale/sale.py +++ b/modules/sale/sale.py @@ -1545,15 +1545,13 @@ class SaleLine(TaxableMixin, sequence_ordered(), ModelSQL, ModelView): 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 - if self.quantity < 0: - quantity *= -1 return quantity def _get_invoiced_quantity(self):