From 8b1cbeb71a4d4575df8bad07275629e6fe3655eb Mon Sep 17 00:00:00 2001 From: Carlos Dauden Date: Thu, 16 Nov 2023 13:48:44 +0100 Subject: [PATCH] [IMP] stock: Avoid unneeded write in _enable_show_reserved method As long as the framework is not able to avoid rewriting values that are already set, we must add checks to avoid triggering multiple processes linked to that value assignment. Example: https://github.com/odoo/odoo/blob/66c11acdbedf8d1bcae6deb8ec54c5da5a3ae16d/addons/stock/models/product_strategy.py#L111 https://github.com/odoo/odoo/blob/11d81b2145e95c50481101a63d3ad1d244279af4/addons/stock/models/stock_move.py#L302-L341 https://github.com/odoo/odoo/blob/daea3d4e10b8fc2c4840fff30474a1203eff55c2/addons/sale_stock/models/sale_order.py#L402-L418 It may be unusual for a field to compute stored depending on a non-stored, but the reality is this. closes odoo/odoo#152026 X-original-commit: 123212a5f5598d91f31869c49ac8d28aba1f698a Signed-off-by: William Henrotin (whe) --- addons/stock/models/product_strategy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/stock/models/product_strategy.py b/addons/stock/models/product_strategy.py index 611f5997ef6..39c78a4cb55 100644 --- a/addons/stock/models/product_strategy.py +++ b/addons/stock/models/product_strategy.py @@ -94,7 +94,7 @@ class StockPutawayRule(models.Model): out_locations = self.location_out_id if out_locations: self.env['stock.picking.type'].with_context(active_test=False)\ - .search([('default_location_dest_id', 'in', out_locations.ids)])\ + .search([('default_location_dest_id', 'in', out_locations.ids), ('show_reserved', '=', False)])\ .write({'show_reserved': True}) def _get_putaway_location(self, product, quantity=0, package=None, packaging=None, qty_by_location=None):