From 083e172dd969303fc818e6a769caea82cec86527 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Tue, 15 Mar 2016 15:33:04 +0100 Subject: [PATCH] [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 --- addons/product_extended/mrp_view.xml | 3 ++- addons/product_extended/product_extended.py | 9 ++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/addons/product_extended/mrp_view.xml b/addons/product_extended/mrp_view.xml index e2a4f20373b..33447ff63ca 100644 --- a/addons/product_extended/mrp_view.xml +++ b/addons/product_extended/mrp_view.xml @@ -7,7 +7,8 @@ - + + diff --git a/addons/product_extended/product_extended.py b/addons/product_extended/product_extended.py index 9b3defeec5b..f652d7bc7a8 100644 --- a/addons/product_extended/product_extended.py +++ b/addons/product_extended/product_extended.py @@ -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()