changeset 3994ba7bd7f8 in modules/purchase:default
details: https://hg.tryton.org/modules/purchase?cmd=changeset;node=3994ba7bd7f8
description:
Count as quantity to invoice only moves that leave the source
issue8951
review266621003
diffstat:
purchase.py | 15 ++++++++++++---
1 files changed, 12 insertions(+), 3 deletions(-)
diffs (25 lines):
diff -r e0511a685d00 -r 3994ba7bd7f8 purchase.py
--- a/purchase.py Sat Dec 14 10:47:54 2019 +0100
+++ b/purchase.py Mon Jan 13 23:54:20 2020 +0100
@@ -1424,9 +1424,18 @@
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