[FIX] base: default company on rate

- Activate multi-company
- Company B is parent of Company A
- Admin is in Company A
- Demo is in Company B
- Create a rate with Demo

The rate is recorded on Company A, not Company B as expected.

This is because we call: `self.env.user._get_company()` which would be
equivalent to `self.env.user.env.user.company_id`. Since the user is
browsed as `sudo`, it returns the company of the Admin.

opw-753139
This commit is contained in:
Nicolas Martinelli
2017-08-02 14:04:35 +02:00
parent b335ae0348
commit ce8c3af3a9
+1 -1
View File
@@ -208,7 +208,7 @@ class CurrencyRate(models.Model):
rate = fields.Float(digits=(12, 6), help='The rate of the currency to the currency of rate 1')
currency_id = fields.Many2one('res.currency', string='Currency', readonly=True)
company_id = fields.Many2one('res.company', string='Company',
default=lambda self: self.env.user._get_company())
default=lambda self: self.env.user.company_id)
@api.model
def name_search(self, name, args=None, operator='ilike', limit=80):