[IMP] hr_work_entry_holidays: half day outside of working hours

Fixes taking a hald day outside of working hours counting as half a day
instead of nothing.

See odoo/odoo#68977

closes odoo/odoo#74015

X-original-commit: 7ad9af5b6fd3086d280b42f6769c66d579dd7f5f
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Signed-off-by: William Braeckman (wbr) <Williambraecky@users.noreply.github.com>
This commit is contained in:
William Braeckman
2021-07-20 09:41:42 +00:00
parent a5a9a9672e
commit 576a33bc4f
@@ -200,7 +200,10 @@ class HrLeave(models.Model):
contracts = employee.sudo()._get_contracts(date_from, date_to, states=['open'])
contracts |= employee.sudo()._get_incoming_contracts(date_from, date_to)
calendar = contracts[:1].resource_calendar_id if contracts else None # Note: if len(contracts)>1, the leave creation will crash because of unicity constaint
return employee._get_work_days_data_batch(date_from, date_to, calendar=calendar)[employee.id]
result = employee._get_work_days_data_batch(date_from, date_to, calendar=calendar)[employee.id]
if self.request_unit_half and result['hours'] > 0:
result['days'] = 0.5
return result
return days