[IMP] base: Added a condition to check currency rate type.

bzr revid: uco@tinyerp.com-20110712113601-slvo0c3590a7dkxf
This commit is contained in:
Ujjvala Collins (OpenERP) 2011-07-12 17:06:01 +05:30
parent 72db8f87cb
commit 5c7075cac6
1 changed files with 5 additions and 1 deletions

View File

@ -36,8 +36,12 @@ class res_currency(osv.osv):
else:
date = time.strftime('%Y-%m-%d')
date = date or time.strftime('%Y-%m-%d')
currency_rate_type_id = context.get('currency_rate_type_id', 0)
for id in ids:
cr.execute("SELECT currency_id, rate FROM res_currency_rate WHERE currency_id = %s AND name <= %s ORDER BY name desc LIMIT 1" ,(id, date))
cr.execute("SELECT currency_id, rate FROM res_currency_rate "\
"WHERE currency_id = %s AND name <= %s AND currency_rate_type_id = %s "\
"ORDER BY name desc LIMIT 1" ,(id, date, currency_rate_type_id))
if cr.rowcount:
id, rate = cr.fetchall()[0]
res[id] = rate