From 7afebbcb031d46f0771e53e3e23139ea2e9b991c Mon Sep 17 00:00:00 2001 From: Martin Quinteros Date: Wed, 7 Jan 2026 15:42:35 -0300 Subject: [PATCH] [REF] purchase_stock_ux: ingnore is_exchange_move into qty retuened into lines --- .../models/purchase_order_line.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/purchase_stock_ux/models/purchase_order_line.py b/purchase_stock_ux/models/purchase_order_line.py index 134ccbbd..e5d40044 100644 --- a/purchase_stock_ux/models/purchase_order_line.py +++ b/purchase_stock_ux/models/purchase_order_line.py @@ -152,12 +152,28 @@ def _onchange_product_qty(self): return {"warning": warning_mess} return {} + @api.depends("qty_received_method", "qty_received_manual") + def _compute_qty_received(self): + super()._compute_qty_received() + for line in self.filtered(lambda l: l.qty_received_method in ["manual", "stock_moves"]): + exchange_move_ids = line.move_ids.filtered( + lambda m: m.state == "done" and m.location_id.usage != "supplier" and m._is_exchange_move_helper() + ) + if exchange_move_ids: + line.qty_received -= sum( + line.product_uom._compute_quantity(move.product_uom_qty, line.product_uom) + for move in exchange_move_ids + ) + @api.depends("order_id.state", "move_ids.state") def _compute_qty_returned(self): for line in self: qty = 0.0 for move in line.move_ids.filtered( - lambda m: m.state == "done" and m.location_id.usage != "supplier" and m.to_refund + lambda m: m.state == "done" + and m.location_id.usage != "supplier" + and m.to_refund + and not m.is_exchange_move ): qty += move.product_uom._compute_quantity(move.product_uom_qty, line.product_uom) line.qty_returned = qty