[FIX] product_extended: _get_variant_count

Due to the _set_product_template_field function, it is not possible
to set the standard price on a product template with more than one variant.

Due to the _compute_product_template_field function, it is not possible
to read the standard price on a product with more than one variant.

The field "standard_price" is in readonly to avoid some problems if the costing
method is in real time.

Closes: #11308

opw:671013
This commit is contained in:
Goffin Simon
2016-03-15 16:55:04 +01:00
parent 3ca42307bc
commit 083e172dd9
2 changed files with 10 additions and 2 deletions
+2 -1
View File
@@ -7,7 +7,8 @@
<field name="inherit_id" ref="mrp.mrp_bom_form_view"/>
<field name="arch" type="xml">
<field name="product_id" position="after">
<field name="standard_price"/>
<field name="get_variant_count" invisible="1"/>
<field name="standard_price" readonly="1" attrs="{'invisible': [('get_variant_count', '&gt;', 1)]}"/>
<newline/>
</field>
</field>
+8 -1
View File
@@ -89,9 +89,16 @@ class product_template(osv.osv):
class product_bom(osv.osv):
_inherit = 'mrp.bom'
def _get_variant_count(self, cr, uid, ids, field_name, arg, context=None):
res = {}
for bom in self.browse(cr, uid, ids, context=context):
res[bom.id] = bom.product_tmpl_id.product_variant_count
return res
_columns = {
'standard_price': fields.related('product_tmpl_id','standard_price',type="float",relation="product.product",string="Standard Price",store=False)
'standard_price': fields.related('product_tmpl_id','standard_price',type="float",relation="product.product",string="Standard Price",store=False),
'get_variant_count': fields.function(_get_variant_count, type='integer', string='Number of variant for the product'),
}
product_bom()