[FIX] sale_margin: convert standard_price to SO currency before using

This commit is contained in:
Joren Van Onder 2017-04-04 10:25:52 -07:00
parent 63ad8b9597
commit 49407e46cb
No known key found for this signature in database
GPG Key ID: E42D0F1A086332F3
1 changed files with 10 additions and 1 deletions

View File

@ -55,7 +55,16 @@ class sale_order_line(osv.osv):
cur = line.order_id.pricelist_id.currency_id
res[line.id] = 0
if line.product_id:
tmp_margin = line.price_subtotal - ((line.purchase_price or line.product_id.standard_price) * line.product_uos_qty)
price = line.purchase_price
if not price:
from_cur = self.pool['res.users'].browse(cr, uid, uid, context=context).company_id.currency_id
cost = line.product_id.standard_price
ctx = context.copy()
ctx['date'] = line.order_id.date_order
price = self.pool['res.currency'].compute(cr, uid, from_cur.id, cur.id, cost, round=False, context=ctx)
tmp_margin = line.price_subtotal - (price * line.product_uos_qty)
res[line.id] = cur_obj.round(cr, uid, cur, tmp_margin)
return res