diff --git a/addons/sale_margin/sale_margin.py b/addons/sale_margin/sale_margin.py index dc8c4dfff3c..72d252a7c11 100644 --- a/addons/sale_margin/sale_margin.py +++ b/addons/sale_margin/sale_margin.py @@ -31,11 +31,15 @@ class sale_order_line(osv.osv): lang=lang, update_tax=update_tax, date_order=date_order, packaging=packaging, fiscal_position=fiscal_position, flag=flag, context=context) if not pricelist: return res + if context is None: + context = {} frm_cur = self.pool.get('res.users').browse(cr, uid, uid).company_id.currency_id.id to_cur = self.pool.get('product.pricelist').browse(cr, uid, [pricelist])[0].currency_id.id if product: purchase_price = self.pool.get('product.product').browse(cr, uid, product).standard_price - price = self.pool.get('res.currency').compute(cr, uid, frm_cur, to_cur, purchase_price, round=False) + ctx = context.copy() + ctx['date'] = date_order + price = self.pool.get('res.currency').compute(cr, uid, frm_cur, to_cur, purchase_price, round=False, context=ctx) res['value'].update({'purchase_price': price}) return res