From 22df13f4fd94f99b51d335ad58e3d1907e238de6 Mon Sep 17 00:00:00 2001 From: "Richard Mathot (OpenERP)" Date: Wed, 23 Apr 2014 09:35:11 +0200 Subject: [PATCH] [FIX] res_currency: Removing unnecessary 'browse' bzr revid: rim@openerp.com-20140423073511-kkjkt0a0baxz3466 --- openerp/addons/base/res/res_currency.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/openerp/addons/base/res/res_currency.py b/openerp/addons/base/res/res_currency.py index b62ed300439..19444786935 100644 --- a/openerp/addons/base/res/res_currency.py +++ b/openerp/addons/base/res/res_currency.py @@ -46,18 +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 currency in self.browse(cr, uid, ids, context=context): + for id in ids: 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', - (currency.id, date, currency_rate_type)) + (id, date, currency_rate_type)) if cr.rowcount: - res[currency.id] = cr.fetchone()[0] + res[id] = cr.fetchone()[0] elif not raise_on_no_rate: - res[currency.id] = 0 + res[id] = 0 else: + currency = self.browse(cr, uid, id, context=context) raise osv.except_osv(_('Error!'),_("No currency rate associated for currency '%s' for the given period" % (currency.name))) return res