From bd5cb5e54af9a311753037b96f032503a35e65bc Mon Sep 17 00:00:00 2001 From: "Ujjvala Collins (OpenERP)" Date: Tue, 23 Aug 2011 17:31:16 +0530 Subject: [PATCH] [IMP] base: Improved code to update the context. bzr revid: uco@tinyerp.com-20110823120116-6mrgalyg77jthxnt --- openerp/addons/base/res/res_currency.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/openerp/addons/base/res/res_currency.py b/openerp/addons/base/res/res_currency.py index 5e69daddb13..8a8067c6ff4 100644 --- a/openerp/addons/base/res/res_currency.py +++ b/openerp/addons/base/res/res_currency.py @@ -125,8 +125,14 @@ class res_currency(osv.osv): if not to_currency_id: to_currency_id = from_currency_id - xc = self.browse(cr, uid, [from_currency_id], context={'currency_rate_type_id': currency_rate_type_from}) - xc1 = self.browse(cr, uid, [to_currency_id], context={'currency_rate_type_id': currency_rate_type_to}) + context.update({'currency_rate_type_id': False}) + if currency_rate_type_from: + context.update({'currency_rate_type_id': currency_rate_type_from}) + if currency_rate_type_to: + context.update({'currency_rate_type_id': currency_rate_type_to}) + + xc = self.browse(cr, uid, [from_currency_id], context=context) + xc1 = self.browse(cr, uid, [to_currency_id], context=context) from_currency = (xc[0].id == from_currency_id and xc[0]) or xc[1] to_currency = (xc1[0].id == to_currency_id and xc1[0]) or xc1[1] if to_currency_id == from_currency_id: