From f8ca7634ca66efcc5e13a7d1e36dbb415fa252d4 Mon Sep 17 00:00:00 2001 From: Martin Geubelle Date: Mon, 27 Jun 2016 16:20:47 +0200 Subject: [PATCH] [FIX] base: rate with correct current user's company Bug introduced in 7eab8e2. As `self.env.user` is browsed with `sudo`, the result of this call will always return the admin's current company and not the user's current company. opw-681809 --- openerp/addons/base/res/res_currency.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openerp/addons/base/res/res_currency.py b/openerp/addons/base/res/res_currency.py index 080c488b378..e5a354b2106 100644 --- a/openerp/addons/base/res/res_currency.py +++ b/openerp/addons/base/res/res_currency.py @@ -36,7 +36,7 @@ class Currency(models.Model): @api.multi def _compute_current_rate(self): date = self._context.get('date') or fields.Datetime.now() - company_id = self._context.get('company_id') or self.env.user._get_company().id + company_id = self._context.get('company_id') or self.env['res.users']._get_company().id # the subquery selects the last rate before 'date' for the given currency/company query = """SELECT c.id, (SELECT r.rate FROM res_currency_rate r WHERE r.currency_id = c.id AND r.name <= %s