[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) <whe@odoo.com>
This commit is contained in:
Arnold Moyaux
2022-09-15 11:05:31 +02:00
parent 14d170e38b
commit 32ea90106d
+1 -1
View File
@@ -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 = {