[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) <whe@odoo.com>
Signed-off-by: Andrea Grazioso (agr) <agr@odoo.com>
This commit is contained in:
Andrea Grazioso (agr-odoo)
2024-01-31 13:47:14 +00:00
parent 556ab11594
commit 521ffebe5a
2 changed files with 6 additions and 1 deletions
@@ -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"];
@@ -18,6 +18,7 @@ patch(ForecastedButtons.prototype, {
additionalContext: {
active_id: this.bomId,
active_product_id: this.productId,
active_model: this.resModel,
activate_availabilities : true,
},
});