[FIX] hr_holidays: Don't check approval rights in onchange

When this method is called in the context of an onchange
`self.ids` is an empty list.

This is a problem when calling `holiday.check_access_rule('write')`
because it does not find any valid holidays and thus raises an AccessError.
This commit is contained in:
Lucas Lefèvre
2019-03-19 09:35:31 +01:00
committed by Yannick Tivisse
parent 0281858c2a
commit 492764c559
2 changed files with 3 additions and 2 deletions
+2 -1
View File
@@ -748,7 +748,8 @@ class HolidaysRequest(models.Model):
current_employee = self.env['hr.employee'].search([('user_id', '=', self.env.uid)], limit=1)
is_officer = self.env.user.has_group('hr_holidays.group_hr_holidays_user')
is_manager = self.env.user.has_group('hr_holidays.group_hr_holidays_manager')
if self.env.in_onchange:
return
for holiday in self:
val_type = holiday.holiday_status_id.validation_type
@@ -486,7 +486,7 @@ class HolidaysAllocation(models.Model):
def _check_approval_update(self, state):
""" Check if target state is achievable. """
current_employee = self.env['hr.employee'].search([('user_id', '=', self.env.uid)], limit=1)
if not current_employee:
if not current_employee or self.env.in_onchange:
return
is_officer = self.env.user.has_group('hr_holidays.group_hr_holidays_user')
is_manager = self.env.user.has_group('hr_holidays.group_hr_holidays_manager')