From 46790bc18de1524ba0714f2d74109450680e2dd6 Mon Sep 17 00:00:00 2001 From: Nicolas Delbovier Date: Wed, 25 Mar 2026 15:54:47 +0100 Subject: [PATCH] [FIX] stock_available_to_promise_release: improve returnable qty calculation Correct the identification of consumed moves by checking done quantities in addition to the move state. The previous logic only considered moves in the 'done' state. However, during certain validation flows, a move might have its `quantity_done` fully set while its `state` hasn't yet been updated. This caused the returnable quantity to be over-calculated, incorrectly preventing the cancellation of moves. By including moves where `product_uom_qty == m.quantity_done`, we accurately capture moves that are effectively finished, regardless of their transient state. --- stock_available_to_promise_release/models/stock_move.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stock_available_to_promise_release/models/stock_move.py b/stock_available_to_promise_release/models/stock_move.py index 4246082e80f..4ca2a4ed375 100644 --- a/stock_available_to_promise_release/models/stock_move.py +++ b/stock_available_to_promise_release/models/stock_move.py @@ -828,7 +828,7 @@ def unrelease(self, safe_unrelease=False): # in case of canceled origin_moves, the quantity to return must # be limited to the quantity not consumed done_dest_moves = done_moves.move_dest_ids.filtered( - lambda m: m.state == "done" + lambda m: m.state == "done" or m.product_uom_qty == m.quantity_done ) returnable_qty = sum(done_moves.mapped("product_qty")) - sum( done_dest_moves.mapped("product_qty")