From bf781cf740cef4ad724b8ccb33a2ff092d0f93ea Mon Sep 17 00:00:00 2001 From: Wolfgang Taferner Date: Tue, 4 Apr 2017 16:17:28 +0200 Subject: [PATCH] [FIX] mrp: BoM count detection in case it is a single variant In case a product is a single variant we should not leave it with a BoM of zero as soon there is a BoM for its template. This would for example hide the `compute_price` object button which relies on the `bom_count`to be visible. BoM is not found for a single variant product and compute price not possible from the `product.product` view although it is implemented actually there. Closes #16237 --- addons/mrp/models/product.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/addons/mrp/models/product.py b/addons/mrp/models/product.py index 7ecc6274636..25ef11da9a3 100644 --- a/addons/mrp/models/product.py +++ b/addons/mrp/models/product.py @@ -44,7 +44,12 @@ class ProductProduct(models.Model): read_group_res = self.env['mrp.bom'].read_group([('product_id', 'in', self.ids)], ['product_id'], ['product_id']) mapped_data = dict([(data['product_id'][0], data['product_id_count']) for data in read_group_res]) for product in self: - product.bom_count = mapped_data.get(product.id, 0) + if product.product_tmpl_id.product_variant_count == 1: + bom_count = mapped_data.get(product.id, product.product_tmpl_id.bom_count) + else: + bom_count = mapped_data.get(product.id, 0) + product.bom_count = bom_count + def _compute_mo_count(self): read_group_res = self.env['mrp.production'].read_group([('product_id', 'in', self.ids)], ['product_id'], ['product_id'])