From f880d89cc473d725405bd694550e64b6a56f9d96 Mon Sep 17 00:00:00 2001
From: Daniel Dico
Date: Mon, 25 Aug 2014 11:16:35 -0400
Subject: [PATCH] [FIX] sale_order_line: use order date to compute currency
instead of current date
---
addons/sale_margin/sale_margin.py | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
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