[FIX] hr_holidays: Fix access error on leave allocation with multi-company
Current Behaviour: As Admin: - Install timeoff and enable Multi company - Create new company and switch to that company - Go to timeoff > Managers > All > Allocations > Create a record An AccessError is raised from `_onchange_type` because it try to access `employee_ids[:1].id` and it may gives employee of another company. Expected Behaviour: After this commit, it will not raise the AccessError. if employee of that company is exist then and then set on leave allocation. so we have already compute field `employee_id`, it will gives employee of current company. closes odoo/odoo#49120 Taskid: 2179571 Closes: #45381 X-original-commit: 73b3d11a0b443116ce91d889397c6d85a13ca1eb Related: odoo/enterprise#9712 Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
This commit is contained in:
committed by
Barad Mahendra
parent
42690cb4da
commit
bc792b225b
@@ -308,7 +308,7 @@ class HolidaysAllocation(models.Model):
|
||||
def _onchange_type(self):
|
||||
if self.holiday_type == 'employee':
|
||||
if not self.employee_id:
|
||||
self.employee_id = self.env.user.employee_ids[:1].id
|
||||
self.employee_id = self.env.user.employee_id.id
|
||||
self.mode_company_id = False
|
||||
self.category_id = False
|
||||
elif self.holiday_type == 'company':
|
||||
@@ -321,7 +321,7 @@ class HolidaysAllocation(models.Model):
|
||||
self.mode_company_id = False
|
||||
self.category_id = False
|
||||
if not self.department_id:
|
||||
self.department_id = self.env.user.employee_ids[:1].department_id.id
|
||||
self.department_id = self.env.user.employee_id.department_id.id
|
||||
elif self.holiday_type == 'category':
|
||||
self.employee_id = False
|
||||
self.mode_company_id = False
|
||||
|
||||
Reference in New Issue
Block a user