From a19c29c6fdb49cb60814c9768035d05eb9e13ff7 Mon Sep 17 00:00:00 2001 From: Ahmed Khalaf Date: Fri, 3 Mar 2023 11:12:50 +0000 Subject: [PATCH] [IMP] stock: set putaway location on sml This commit adds a check to avoid forcing a write on the sml even if the putway location is the same on the sml, which avoids unnecessary additional costly _gather() calls during the quant updates in the write Taskid: 3090913 Part-of: odoo/odoo#106006 --- addons/stock/models/stock_move_line.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/stock/models/stock_move_line.py b/addons/stock/models/stock_move_line.py index 9420eb3ae08..7ce871dbd10 100644 --- a/addons/stock/models/stock_move_line.py +++ b/addons/stock/models/stock_move_line.py @@ -251,9 +251,11 @@ class StockMoveLine(models.Model): else: for sml in smls: qty = max(sml.reserved_uom_qty, sml.qty_done) - sml.location_dest_id = sml.move_id.location_dest_id.with_context(exclude_sml_ids=excluded_smls.ids)._get_putaway_strategy( + putaway_loc_id = sml.move_id.location_dest_id.with_context(exclude_sml_ids=excluded_smls.ids)._get_putaway_strategy( sml.product_id, quantity=qty, packaging=sml.move_id.product_packaging_id, ) + if putaway_loc_id != sml.location_dest_id: + sml.location_dest_id = putaway_loc_id excluded_smls -= sml def _get_default_dest_location(self):