From f7ff3fa752f952269bc3b0bfcc9db899a94c4c16 Mon Sep 17 00:00:00 2001 From: Mario Arias Badila Date: Thu, 25 Jan 2024 15:25:42 -0600 Subject: [PATCH] Fix current company from env in multi company self.env.user_id.company_id returns the default company linked to current user, not the "Actual" company the user is working on. It is even possible that "default" company is not selected, triggering a security rule error. Correct use is self.env.company, that will provide the actual company the user has active. --- hr_multi_company/models/hr_salary_rule_category.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hr_multi_company/models/hr_salary_rule_category.py b/hr_multi_company/models/hr_salary_rule_category.py index 53dcfd95..9247869a 100644 --- a/hr_multi_company/models/hr_salary_rule_category.py +++ b/hr_multi_company/models/hr_salary_rule_category.py @@ -30,4 +30,4 @@ class HrSalaryRuleCategory(models.Model): company_id = fields.Many2one(comodel_name='res.company', string='Company', copy=False, readonly=True, help="Company of the category.", - default=lambda self: self.env.user.company_id) + default=lambda self: self.env.company)