diff --git a/stock_warehouse_flow/models/stock_move.py b/stock_warehouse_flow/models/stock_move.py index d8ad94c7a2..826b18a562 100644 --- a/stock_warehouse_flow/models/stock_move.py +++ b/stock_warehouse_flow/models/stock_move.py @@ -17,7 +17,11 @@ def _action_confirm(self, merge=True, merge_into=False): if not move._apply_flow_on_action_confirm(): move_ids_to_confirm.append(move.id) continue - move_ids_to_confirm += FLOW._search_and_apply_for_move(move).ids + # Do not assign a picking within the _apply_on_move method + # because it gets called later from _action_confirm itself + move_ids_to_confirm += FLOW._search_and_apply_for_move( + move, assign_picking=False + ).ids moves_to_confirm = self.browse(move_ids_to_confirm) return super(StockMove, moves_to_confirm)._action_confirm( merge=merge, merge_into=merge_into diff --git a/stock_warehouse_flow/models/stock_warehouse_flow.py b/stock_warehouse_flow/models/stock_warehouse_flow.py index e7932464c1..36ff490d84 100644 --- a/stock_warehouse_flow/models/stock_warehouse_flow.py +++ b/stock_warehouse_flow/models/stock_warehouse_flow.py @@ -426,14 +426,14 @@ def _search_for_move(self, move): return self.search(domain) @api.model - def _search_and_apply_for_move(self, move): + def _search_and_apply_for_move(self, move, assign_picking=True): move.ensure_one() flows = self._search_for_move(move) if not flows: return move - return flows.apply_on_move(move) + return flows.apply_on_move(move, assign_picking) - def apply_on_move(self, move): + def apply_on_move(self, move, assign_picking=True): move_ids = [] flows = self for flow in self: @@ -444,7 +444,7 @@ def apply_on_move(self, move): # Try to apply the rest of the flows to the split move for split_move in split_moves: move_ids += (flows - flow).apply_on_move(split_move).ids - flow._apply_on_move(move) + flow._apply_on_move(move, assign_picking) return move.browse(move_ids) raise UserError( _( @@ -521,7 +521,7 @@ def split_move(self, move): return self._split_move_simple(move) return split_moves - def _apply_on_move(self, move): + def _apply_on_move(self, move, assign_picking=True): """Apply the flow configuration on the move.""" if not self: return False @@ -535,7 +535,8 @@ def _apply_on_move(self, move): ) move.procure_method = rule.procure_method move.rule_id = rule - move._assign_picking() + if assign_picking: + move._assign_picking() def write(self, vals): res = super().write(vals)