From 7e724f96c55815728d478a889ff5f1a0314dcc16 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Mon, 12 Mar 2018 14:03:55 +0100 Subject: [PATCH] [FIX] product: display Cost price of product The 'Cost' price should be displayed in the main form view of `product.product`, not only the simplified view. The reason is that the field `product_variant_count` has the same value for the product and the template, therefore it cannot be used to make the distinction between the two models. To do so, we need to reintroduce the `is_product_variant` field to make the distinction between `product.product` and `product.template`. opw-1814973 --- addons/product/models/product_template.py | 8 ++++++++ addons/product/views/product_views.xml | 5 +++-- 2 files changed, 11 insertions(+), 2 deletions(-) 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 @@ +