[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
This commit is contained in:
committed by
Nicolas Martinelli
parent
56749cf098
commit
7e724f96c5
@@ -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:
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
</header>
|
||||
<sheet>
|
||||
<field name='product_variant_count' invisible='1'/>
|
||||
<field name='is_product_variant' invisible='1'/>
|
||||
<field name="id" invisible="True"/>
|
||||
<div class="oe_button_box" name="button_box">
|
||||
<button name="toggle_active" type="object"
|
||||
@@ -48,8 +49,8 @@
|
||||
</group>
|
||||
<group name="group_standard_price">
|
||||
<field name="list_price" widget='monetary' options="{'currency_field': 'currency_id', 'field_digits': True}"/>
|
||||
<label for="standard_price" groups="base.group_user" attrs="{'invisible': [('product_variant_count', '>', 1)]}"/>
|
||||
<div name="standard_price_uom" groups="base.group_user" attrs="{'invisible': [('product_variant_count', '>', 1)]}">
|
||||
<label for="standard_price" groups="base.group_user" attrs="{'invisible': [('product_variant_count', '>', 1), ('is_product_variant', '=', False)]}"/>
|
||||
<div name="standard_price_uom" groups="base.group_user" attrs="{'invisible': [('product_variant_count', '>', 1), ('is_product_variant', '=', False)]}">
|
||||
<field name="standard_price" widget='monetary' options="{'currency_field': 'currency_id', 'field_digits': True}"/>
|
||||
</div>
|
||||
<field name="company_id" groups="base.group_multi_company"
|
||||
|
||||
Reference in New Issue
Block a user