Skip to content

Commit

Permalink
Merge PR OCA#773 into 16.0
Browse files Browse the repository at this point in the history
Signed-off-by jbaudoux
  • Loading branch information
OCA-git-bot committed Nov 21, 2023
2 parents d608609 + 9f470ab commit 03af320
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
6 changes: 5 additions & 1 deletion stock_warehouse_flow/models/stock_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 7 additions & 6 deletions stock_warehouse_flow/models/stock_warehouse_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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(
_(
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit 03af320

Please sign in to comment.