From 521ffebe5a28fba348de95380721cd6434d2e1b6 Mon Sep 17 00:00:00 2001 From: "Andrea Grazioso (agr-odoo)" Date: Wed, 17 Jan 2024 11:02:09 +0000 Subject: [PATCH] [FIX] mrp: Manufacturing Forecast access from template Have a product template with bom Ensure the product variant has not the same id of the template (Add and remove a template variant) In the product page > Hit "forecasted" smart button > "Manufacturing Forecast" Error will raise: Missing record Record does not exist or has been deleted. This occurs because when opening the Manufacturing Forecast from the template product we are searching the variant using the id of the template product opw-3636661 closes odoo/odoo#151776 X-original-commit: df7b80f24bc6ef20d3aea25e9597807f5a6a0195 Signed-off-by: William Henrotin (whe) Signed-off-by: Andrea Grazioso (agr) --- .../static/src/components/bom_overview/mrp_bom_overview.js | 6 +++++- addons/mrp/static/src/mrp_forecasted/forecasted_buttons.js | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/addons/mrp/static/src/components/bom_overview/mrp_bom_overview.js b/addons/mrp/static/src/components/bom_overview/mrp_bom_overview.js index 87e0c3b024f..0b7344d752a 100644 --- a/addons/mrp/static/src/components/bom_overview/mrp_bom_overview.js +++ b/addons/mrp/static/src/components/bom_overview/mrp_bom_overview.js @@ -48,7 +48,11 @@ export class BomOverviewComponent extends Component { async initBomData() { const variantId = this.props.action.context.active_product_id; - this.state.currentVariantId = variantId ? variantId : false; + const resModel = this.props.action.context.active_model; + this.state.currentVariantId = false; + if (resModel === 'product.product' && variantId !== undefined) { + this.state.currentVariantId = variantId; + } const bomData = await this.getBomData(); this.state.bomQuantity = bomData["bom_qty"]; diff --git a/addons/mrp/static/src/mrp_forecasted/forecasted_buttons.js b/addons/mrp/static/src/mrp_forecasted/forecasted_buttons.js index ae1781fb9c1..7cfb0cc7475 100644 --- a/addons/mrp/static/src/mrp_forecasted/forecasted_buttons.js +++ b/addons/mrp/static/src/mrp_forecasted/forecasted_buttons.js @@ -18,6 +18,7 @@ patch(ForecastedButtons.prototype, { additionalContext: { active_id: this.bomId, active_product_id: this.productId, + active_model: this.resModel, activate_availabilities : true, }, });