[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
This commit is contained in:
Martin Geubelle
2016-06-27 16:20:47 +02:00
parent db99c65f7b
commit f8ca7634ca
+1 -1
View File
@@ -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