From 78cc28ffc87bb8fb6ea5000642c4a7b10bc0f505 Mon Sep 17 00:00:00 2001 From: "Laurent Mignonn (ACSONE)" Date: Mon, 14 Oct 2024 16:56:04 +0200 Subject: [PATCH] [FIX] stock_available_to_promise_release: normal outgoing are mergeable outgoing moves from unreleasable pickings are mergeable by default. This fix is required to avoid to disalbe the merge of moves from outgoing picking when the module is installed but the associated stock.rule is not configured to defer the pull of not available qty --- .../models/stock_move.py | 4 +++- .../tests/test_merge_moves.py | 12 ++++++++++++ 2 files changed, 15 insertions(+), 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 d59d90eb59..ac237ca06b 100644 --- a/stock_available_to_promise_release/models/stock_move.py +++ b/stock_available_to_promise_release/models/stock_move.py @@ -787,7 +787,9 @@ def write(self, vals): def _is_mergeable(self): self.ensure_one() return self.state not in ("done", "cancel") and ( - self.picking_type_id.code != "outgoing" or self.unrelease_allowed + self.picking_type_id.code != "outgoing" + or not self._is_unreleaseable() + or self.unrelease_allowed ) def _update_candidate_moves_list(self, candidate_moves): diff --git a/stock_available_to_promise_release/tests/test_merge_moves.py b/stock_available_to_promise_release/tests/test_merge_moves.py index 5e08bd8642..cff7ee2cc2 100644 --- a/stock_available_to_promise_release/tests/test_merge_moves.py +++ b/stock_available_to_promise_release/tests/test_merge_moves.py @@ -136,3 +136,15 @@ def test_unrelease_at_move_merge_merged(self): self.assertEqual(1, len(move)) self.assertEqual(2 + original_qty_1 + original_qty_2, move.product_uom_qty) self.assertEqual(2, move.move_line_ids.qty_done) + + def test_default_merge(self): + # check that the merge is still working when the available_to_promise_defer_pull + # is False + self.wh.delivery_route_id.write( + { + "available_to_promise_defer_pull": False, + } + ) + # run a new procurement for the same product in the shipment 1 + self._procure(2) + self.assertEqual(1, len(self.shipping1.move_ids))