From 93446d0cf7a2eb6ceb1d5b358c87050258ee77b2 Mon Sep 17 00:00:00 2001 From: clesgow Date: Fri, 17 Mar 2023 14:04:15 +0000 Subject: [PATCH] [FIX] mrp: fix forecast for product template Following 873d6d9, 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#115776 X-original-commit: 93f6bf8dc5319082579a2b4ecbc48b482b81cc9d Signed-off-by: Arnold Moyaux (arm) Signed-off-by: Quentin Wolfs (quwo) --- addons/mrp/static/src/mrp_forecasted/forecasted_buttons.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/mrp/static/src/mrp_forecasted/forecasted_buttons.js b/addons/mrp/static/src/mrp_forecasted/forecasted_buttons.js index 25417bcfa8a..ed563727962 100644 --- a/addons/mrp/static/src/mrp_forecasted/forecasted_buttons.js +++ b/addons/mrp/static/src/mrp_forecasted/forecasted_buttons.js @@ -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]; }); },