[FIX] product_visible_discount: don't compute negative discount, also prevent zero division
bzr revid: mat@openerp.com-20131023132646-8l760d4swsq42zzo
This commit is contained in:
parent
80e142cca3
commit
d2042182b4
|
@ -87,12 +87,13 @@ class sale_order_line(osv.osv):
|
|||
pricelists = pricelist_obj.read(cr,uid,[pricelist],['visible_discount'])
|
||||
|
||||
new_list_price = get_real_price(list_price, product.id, qty, uom, pricelist)
|
||||
if (price/new_list_price > 0):
|
||||
result['discount'] = 0.0
|
||||
result['price_unit'] = price
|
||||
else:
|
||||
if(len(pricelists)>0 and pricelists[0]['visible_discount'] and list_price[pricelist] != 0):
|
||||
discount= (price/new_list_price)
|
||||
if len(pricelists)>0 and pricelists[0]['visible_discount'] and list_price[pricelist] != 0 and new_list_price != 0:
|
||||
discount = (new_list_price - price) / new_list_price * 100
|
||||
if discount > 0:
|
||||
result['price_unit'] = new_list_price
|
||||
result['discount'] = discount
|
||||
else:
|
||||
result['discount'] = 0.0
|
||||
else:
|
||||
result['discount'] = 0.0
|
||||
return res
|
||||
|
|
Loading…
Reference in New Issue