From 32ea90106d1167374f5e9bb8683f2aaec6092720 Mon Sep 17 00:00:00 2001 From: Arnold Moyaux Date: Tue, 13 Sep 2022 16:06:40 +0000 Subject: [PATCH] [FIX] stock: _compute_qty_order should not take environement context savepoint do a flush that throw the current context and then recompute the stored field (with a random matching context from the transaction). In the case of qty_to_order, it will call qty_forecast and then _compute_quantities on product.product. Currently it will call _compute_quantities with a mix of self.env.context (from the transaction) and a context generated from the orderpoint (with deterministic data). But sometimes in the context took from the transaction it could remain some other key used by _compute_quantities (e.g. warehouse_id). Since qty_to_order doens't depends from context it should not use self.env.context and only use the deterministic context from the stock.orderpoint closes odoo/odoo#100150 X-original-commit: 79694a88978ebc1213d6ba0ac0dcc59640f16d04 Signed-off-by: William Henrotin (whe) --- addons/stock/models/stock_orderpoint.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/stock/models/stock_orderpoint.py b/addons/stock/models/stock_orderpoint.py index bdee4f74590..a6117c3f1b2 100644 --- a/addons/stock/models/stock_orderpoint.py +++ b/addons/stock/models/stock_orderpoint.py @@ -249,7 +249,7 @@ class StockWarehouseOrderpoint(models.Model): orderpoint.qty_forecast = False continue orderpoint_context = orderpoint._get_product_context() - product_context = frozendict({**self.env.context, **orderpoint_context}) + product_context = frozendict({**orderpoint_context}) orderpoints_contexts[product_context] |= orderpoint for orderpoint_context, orderpoints_by_context in orderpoints_contexts.items(): products_qty = {