Count as quantity to invoice only moves that leave the source

issue8951
review266621003
This commit is contained in:
Cédric Krier committed 2020-01-13 23:54:20 +01:00
1 parent 00f1e57165
commit fecfe235f5
1 file changed
+12 -3
+12 -3
View File
@@ -1424,9 +1424,18 @@ class PurchaseLine(sequence_ordered(), ModelSQL, ModelView):
elif self.purchase.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 from_location
# as it is what matters for purchase
src_type = self.from_location.type
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