Skip to content
Snippets Groups Projects
Commit 93f6bf8d authored by clesgow's avatar clesgow
Browse files

[FIX] mrp: fix forecast for product template


Following 873d6d92, the forecast would now redirect correctly to the
corresponding bom when a `product.product` was used.
The issue is that `bom_variant_ids` doesn't exist on `product.template`,
raising a traceback when the forecast was accessed through the product
themselves instead of their variants

closes odoo/odoo#115716

Signed-off-by: default avatarArnold Moyaux (arm) <arm@odoo.com>
parent adb18af1
No related branches found
No related tags found
No related merge requests found
......@@ -8,8 +8,9 @@ patch(ForecastedButtons.prototype, 'mrp.ForecastedButtons',{
setup() {
this._super.apply();
onWillStart(async () =>{
const res = (await this.orm.call(this.resModel, 'read', [this.productId], {fields: ['bom_ids', 'variant_bom_ids']}))[0];
this.bomId = res.variant_bom_ids[0] || res.bom_ids[0];
const fields = this.resModel === "product.template" ? ['bom_ids'] : ['bom_ids', 'variant_bom_ids'];
const res = (await this.orm.call(this.resModel, 'read', [this.productId], { fields }))[0];
this.bomId = res.variant_bom_ids ? res.variant_bom_ids[0] || res.bom_ids[0] : res.bom_ids[0];
});
},
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment