From e4f04479d1c995905d961d0f78b379cde00381cf Mon Sep 17 00:00:00 2001 From: Denis Roussel Date: Fri, 22 Nov 2024 15:40:03 +0100 Subject: [PATCH] [IMP] stock_picking_putaway_recompute: Apply first the move destination location This is more correct as the original location before applying the putaways is the stock move destination location. --- .../models/stock_move_line.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/stock_picking_putaway_recompute/models/stock_move_line.py b/stock_picking_putaway_recompute/models/stock_move_line.py index 6237802fcaf..dc59b40b6de 100644 --- a/stock_picking_putaway_recompute/models/stock_move_line.py +++ b/stock_picking_putaway_recompute/models/stock_move_line.py @@ -43,7 +43,14 @@ def _recompute_putaways(self) -> None: Launches the computation of putaways on operations that are allowed to. """ - self._filtered_for_putaway_recompute()._apply_putaway_strategy() + to_recompute_lines = self._filtered_for_putaway_recompute() + # Reset location destinations to their move destination + # First, protect the field from recomputations as + # value will be reaffected afterwards. + with to_recompute_lines.env.protecting(["location_dest_id"],to_recompute_lines): + for line in to_recompute_lines: + line.location_dest_id = line.move_id.location_dest_id + to_recompute_lines._apply_putaway_strategy() def action_recompute_putaways(self): self._recompute_putaways()