From b0c17397df7b3255a4bc9e500c9837f9fc82696e Mon Sep 17 00:00:00 2001 From: "Bharat R. Devnani (OpenERP)" Date: Wed, 12 Feb 2014 17:16:11 +0530 Subject: [PATCH] [IMP] improved the code to get the name of currency instead of id bzr revid: bde@tinyerp.com-20140212114611-et0fw2dlwwjuq39p --- openerp/addons/base/res/res_currency.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/openerp/addons/base/res/res_currency.py b/openerp/addons/base/res/res_currency.py index 1419cc7ccb4..b62ed300439 100644 --- a/openerp/addons/base/res/res_currency.py +++ b/openerp/addons/base/res/res_currency.py @@ -46,19 +46,19 @@ class res_currency(osv.osv): currency_rate_type = context.get('currency_rate_type_id') or None # ... and use 'is NULL' instead of '= some-id'. operator = '=' if currency_rate_type else 'is' - for id in ids: + for currency in self.browse(cr, uid, ids, context=context): cr.execute('SELECT rate FROM res_currency_rate ' 'WHERE currency_id = %s ' 'AND name <= %s ' 'AND currency_rate_type_id ' + operator + ' %s ' 'ORDER BY name desc LIMIT 1', - (id, date, currency_rate_type)) + (currency.id, date, currency_rate_type)) if cr.rowcount: - res[id] = cr.fetchone()[0] + res[currency.id] = cr.fetchone()[0] elif not raise_on_no_rate: - res[id] = 0 + res[currency.id] = 0 else: - raise osv.except_osv(_('Error!'),_("No currency rate associated for currency %d for the given period" % (id))) + raise osv.except_osv(_('Error!'),_("No currency rate associated for currency '%s' for the given period" % (currency.name))) return res _name = "res.currency"