[FIX] hr_holidays: fix logic of a onchange on leave allocation

- When changing the `holiday_type` of a leave allocation while having an
  employee set and if this `holiday_type` has as its value `employee`
  the field `employee_id` is set to False.

  This is not the intended behavior. We want the field `employee_id`
  to be filled if the `holiday_type` is set to `employee`.

closes odoo/odoo#32886

Signed-off-by: Denis Ledoux <beledouxdenis@users.noreply.github.com>
This commit is contained in:
Toufik Ben Jaa
2019-04-23 15:22:16 +00:00
parent 9617e79e58
commit 30e7a64cbd
@@ -243,8 +243,8 @@ class HolidaysAllocation(models.Model):
@api.onchange('holiday_type')
def _onchange_type(self):
if self.holiday_type == 'employee' and not self.employee_id:
if self.env.user.employee_ids:
if self.holiday_type == 'employee':
if not self.employee_id and self.env.user.employee_ids:
self.employee_id = self.env.user.employee_ids[0]
elif self.holiday_type == 'department':
if self.env.user.employee_ids: