summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexis de Lattre <alexis@via.ecp.fr>2014-10-27 16:27:53 +0100
committerMartin Trigaux <mat@odoo.com>2015-02-10 14:06:29 +0530
commit45485fe1d67f8a95e043b076da29951c2245fe41 (patch)
treee5e58b8424b9c19bbdf1633a33ae8a532adf1de3
parenta11100adb8304297865668ac999b574055af8ec4 (diff)
[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
-rw-r--r--addons/account/report/account_invoice_report.py11
1 files 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()