From 380a7e97f566ac7ace446bd61bcea6f2ee544bd5 Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Fri, 18 Jul 2014 11:33:09 +0200 Subject: [PATCH] [FIX] product: user who don't use product variant can't edit the price of the product in product view. This behavior is not understandable. Add a function inverse to set the value (remove the variante price before change the list_price of the template) --- addons/product/product.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/addons/product/product.py b/addons/product/product.py index f8b38c68ebe..32b3a0bfbf1 100644 --- a/addons/product/product.py +++ b/addons/product/product.py @@ -811,7 +811,6 @@ class product_product(osv.osv): return res def _product_lst_price(self, cr, uid, ids, name, arg, context=None): - res = {} product_uom_obj = self.pool.get('product.uom') res = dict.fromkeys(ids, 0.0) @@ -826,6 +825,18 @@ class product_product(osv.osv): return res + def _set_product_lst_price(self, cr, uid, id, name, value, args, context=None): + product_uom_obj = self.pool.get('product.uom') + + product = self.browse(cr, uid, id, context=context) + if 'uom' in context: + uom = product.uos_id or product.uom_id + value = product_uom_obj._compute_price(cr, uid, + context['uom'], value, uom.id) + value = value - product.price_extra + + return product.write({'list_price': value}, context=context) + def _get_partner_code_name(self, cr, uid, ids, product, partner_id, context=None): for supinfo in product.seller_ids: if supinfo.name.id == partner_id: @@ -893,7 +904,7 @@ class product_product(osv.osv): _columns = { 'price': fields.function(_product_price, type='float', string='Price', digits_compute=dp.get_precision('Product Price')), 'price_extra': fields.function(_get_price_extra, type='float', string='Variant Extra Price', help="This is le sum of the extra price of all attributes"), - 'lst_price': fields.function(_product_lst_price, type='float', string='Public Price', digits_compute=dp.get_precision('Product Price')), + 'lst_price': fields.function(_product_lst_price, fnct_inv=_set_product_lst_price, type='float', string='Public Price', digits_compute=dp.get_precision('Product Price')), 'code': fields.function(_product_code, type='char', string='Internal Reference'), 'partner_ref' : fields.function(_product_partner_ref, type='char', string='Customer ref'), 'default_code' : fields.char('Internal Reference', select=True),