From 6eb88addc67c5d1cc39016a9ca85befd436db825 Mon Sep 17 00:00:00 2001 From: Mario Arias Badila Date: Thu, 25 Jan 2024 15:24:27 -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_payslip_run.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hr_multi_company/models/hr_payslip_run.py b/hr_multi_company/models/hr_payslip_run.py index 73321e0b..36f17f64 100644 --- a/hr_multi_company/models/hr_payslip_run.py +++ b/hr_multi_company/models/hr_payslip_run.py @@ -30,4 +30,4 @@ class HrPayslipRun(models.Model): company_id = fields.Many2one(comodel_name='res.company', string='Company', copy=False, readonly=True, help="Company od the payslip.", - default=lambda self: self.env.user.company_id) + default=lambda self: self.env.company)