From 0b414cb8145381cd8a3946aae9cec1601b111238 Mon Sep 17 00:00:00 2001 From: Simon Lejeune Date: Fri, 12 Oct 2018 09:00:24 +0200 Subject: [PATCH] [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 --- addons/sale_stock/models/sale_order.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/sale_stock/models/sale_order.py b/addons/sale_stock/models/sale_order.py index 64d4398cba1..b87ead381f0 100644 --- a/addons/sale_stock/models/sale_order.py +++ b/addons/sale_stock/models/sale_order.py @@ -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)