diff --git a/addons/product/models/product_template.py b/addons/product/models/product_template.py index a04bec14625..f8a4ffea081 100644 --- a/addons/product/models/product_template.py +++ b/addons/product/models/product_template.py @@ -117,6 +117,7 @@ class ProductTemplate(models.Model): active = fields.Boolean('Active', default=True, help="If unchecked, it will allow you to hide the product without removing it.") color = fields.Integer('Color Index') + is_product_variant = fields.Boolean(string='Is a product variant', compute='_compute_is_product_variant') attribute_line_ids = fields.One2many('product.attribute.line', 'product_tmpl_id', 'Product Attributes') product_variant_ids = fields.One2many('product.product', 'product_tmpl_id', 'Products', required=True) # performance: product_variant_id provides prefetching on the first product variant only @@ -234,6 +235,13 @@ class ProductTemplate(models.Model): for template in (self - unique_variants): template.weight = 0.0 + def _compute_is_product_variant(self): + for template in self: + if template._name == 'product.template': + template.is_product_variant = False + else: + template.is_product_variant = True + @api.one def _set_weight(self): if len(self.product_variant_ids) == 1: diff --git a/addons/product/views/product_views.xml b/addons/product/views/product_views.xml index 5f3228ac1a1..341dded8adf 100644 --- a/addons/product/views/product_views.xml +++ b/addons/product/views/product_views.xml @@ -16,6 +16,7 @@ +