diff --git a/purchase.py b/purchase.py index 536df16c84..e0d7757c28 100644 --- a/purchase.py +++ b/purchase.py @@ -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