[FIX] hr_work_entry_holidays: fix dates computaiton in write

We need to filter out records without `request_date_from` and
`request_date_to` to avoid the error:
```
  File "/tmp/tmpiaelju95/odoo/17.0/addons/hr_work_entry_holidays/models/hr_leave.py", line 180, in write
    stop = datetime.combine(max(stop_dates) + relativedelta(days=1), time.max)
TypeError: '>' not supported between instances of 'datetime.date' and 'bool'
```

Issue observed in test upgrades of `l10n_hk_hr_payroll`

closes odoo/odoo#140286

Signed-off-by: Sofie Gvaladze (sgv) <sgv@odoo.com>
This commit is contained in:
Alvaro Fuentes
2023-11-02 15:10:58 +00:00
parent a99c83feaa
commit 74c291ef5f
@@ -174,8 +174,8 @@ Contracts:
# can lie in this range due to time zone reasons.
# (We can't use date_from and date_to as they are not yet computed at
# this point.)
start_dates = self.mapped('request_date_from') + [fields.Date.to_date(vals.get('request_date_from', False)) or datetime.max.date()]
stop_dates = self.mapped('request_date_to') + [fields.Date.to_date(vals.get('request_date_to', False)) or datetime.min.date()]
start_dates = self.filtered('request_date_from').mapped('request_date_from') + [fields.Date.to_date(vals.get('request_date_from', False)) or datetime.max.date()]
stop_dates = self.filtered('request_date_to').mapped('request_date_to') + [fields.Date.to_date(vals.get('request_date_to', False)) or datetime.min.date()]
start = datetime.combine(min(start_dates) - relativedelta(days=1), time.min)
stop = datetime.combine(max(stop_dates) + relativedelta(days=1), time.max)
with self.env['hr.work.entry']._error_checking(start=start, stop=stop, skip=skip_check, employee_ids=employee_ids):