From 45485fe1d67f8a95e043b076da29951c2245fe41 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Mon, 27 Oct 2014 16:27:53 +0100 Subject: [PATCH] [FIX] account: multicompany with currency rates A record rule exists on currencies but not on rates. If creates multiple currencies with rate = 1, we could fetch the wrong one in the search and get a security exception while trying to convert rates. Fixes #3323, opw 626353 --- addons/account/report/account_invoice_report.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/addons/account/report/account_invoice_report.py b/addons/account/report/account_invoice_report.py index 4c291cdaf36..f1c029f9ab0 100644 --- a/addons/account/report/account_invoice_report.py +++ b/addons/account/report/account_invoice_report.py @@ -36,8 +36,15 @@ class account_invoice_report(osv.osv): context={} currency_obj = self.pool.get('res.currency') currency_rate_obj = self.pool.get('res.currency.rate') - user_currency_id = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.currency_id.id - currency_rate_id = currency_rate_obj.search(cr, uid, [('rate', '=', 1)], limit=1, context=context)[0] + user = self.pool.get('res.users').browse(cr, uid, uid, context=context) + user_currency_id = user.company_id.currency_id.id + currency_rate_id = currency_rate_obj.search( + cr, uid, [ + ('rate', '=', 1), + '|', + ('currency_id.company_id', '=', user.company_id.id) + ('currency_id.company_id', '=', False) + ], limit=1, context=context)[0] base_currency_id = currency_rate_obj.browse(cr, uid, currency_rate_id, context=context).currency_id.id res = {} ctx = context.copy()