[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)

This commit is contained in:
Christophe Matthieu 2014-07-18 11:33:09 +02:00
parent 15174e9a70
commit 380a7e97f5
1 changed files with 13 additions and 2 deletions

View File

@ -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),