Count as quantity to invoice only moves that reach the destination

issue8951
review264961002
This commit is contained in:
Cédric Krier committed 2020-01-13 23:54:01 +01:00
1 parent 7a82b36845
commit 528b46706d
1 file changed
+12 -3
+12 -3
View File
@@ -1371,9 +1371,18 @@ class SaleLine(sequence_ordered(), ModelSQL, ModelView):
elif self.sale.invoice_method == 'shipment':
quantity = 0.0
for move in self.moves:
if move.state == 'done':
quantity += Uom.compute_qty(move.uom, move.quantity,
self.unit)
if move.state != 'done':
continue
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
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