[FIX] stock_account: getting value from context in stock valuation layer

Attribute Error: 'frozendict' object has no attribute 'default_product_id'
traceback that occurs in stock/stock_quant: action_inventory_at_date
was caught by a sentry.

steps to produce:-

- Install inventory module
- Select any product from the menu item/reporting/stock
- Click replenish button & from that replenish wizard, select the product again
- Then click the forecasted stat button and in forecast click the On Hand button
- Then click Inventory At Date.

At this moment you find a traceback.

Because default_product_id is not getting from the context in inventory.

Applying these changes will resolve this issue.

sentry:-4148733813

closes odoo/odoo#122741

X-original-commit: ca58b13d63702ac2ec8d74b855b90058bf18eb7b
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
This commit is contained in:
uso-odoo
2023-05-30 13:03:31 +02:00
parent 5fd185ef85
commit 113d9f1d8d
@@ -78,9 +78,9 @@ class StockValuationLayer(models.Model):
# inventory at a given date.
context = {}
if ("default_product_id" in self.env.context):
context.product_id = self.env.context.default_product_id
elif ("product_tmpl_id" in self.env.context):
context.product_tmpl_id = self.env.context.product_tmpl_id
context["product_id"] = self.env.context["default_product_id"]
elif ("default_product_tmpl_id" in self.env.context):
context["product_tmpl_id"] = self.env.context["default_product_tmpl_id"]
return {
"res_model": "stock.quantity.history",