[FIX] sale_stock: return of return and delivered quantity

The code ignored return of return when computing the delivered quantity
of a so line (in this part of the code, if a move has a destination
location set a customer, it'd be a return of return of a delivery).

We now update the delivered quantity is the return of return as the
`to_refund` flag enabled, meaning the user ticked the option to update
the quantity on the so line.

opw-1884683
This commit is contained in:
Simon Lejeune
2018-10-12 10:21:14 +02:00
committed by Nicolas Martinelli
parent 3df584f5a6
commit 0b414cb814
+2 -1
View File
@@ -181,7 +181,8 @@ class SaleOrderLine(models.Model):
qty = 0.0
for move in self.procurement_ids.mapped('move_ids').filtered(lambda r: r.state == 'done' and not r.scrapped):
if move.location_dest_id.usage == "customer":
if not move.origin_returned_move_id:
# FORWARD-PORT NOTICE: "to_refund_so" to rename to "to_refund" in v11
if not move.origin_returned_move_id or (move.origin_returned_move_id and move.to_refund_so):
qty += move.product_uom._compute_quantity(move.product_uom_qty, self.product_uom)
elif move.location_dest_id.usage != "customer" and move.to_refund_so:
qty -= move.product_uom._compute_quantity(move.product_uom_qty, self.product_uom)