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
This commit is contained in:
@@ -1735,15 +1735,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):
|
||||
|
||||
@@ -1729,15 +1729,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):
|
||||
|
||||
Reference in New Issue
Block a user