[FW][FIX] hr_work_entry_contract, hr_work_entry_holidays: split leaves by type
Steps to reproduce:
-
Download payroll and Time off
-
Time Off > Configuration > Time off types
-
In Paid and unpaid type, set 'Take Time Off in' to Hours
-
Employees > Pick one > Time off
-
Click calendar day and create 2 leaves: -- Paid type, Custom hours from 8:00 to 9:00 -- Unpaid type, Custom hours from 9:00 o 10:00
-
Time off > Management > Time off
-
Approve and validate both leaves
-
The employee needs to have a running contract so if needed -- Payroll > Contracts > Contracts > New
-
Payroll > Regenerate work entries for your employee
-
Leaves are generated as a single block of type 'Generic time off'
The leaves are merged. The Interval class sorts its entries' boundaries in such a way that it will see the start of an entry before the stop of the previous one if the start/stop time are the same. Its counterpart WorkIntervals does not merge overlapping entries.
i.e with entries 8:00-9:00 and 9:00-10:00 Intervals will interpret as: 8:00 start, 9:00 start, 9:00 stop, 10:00 stop => Merged entries. And WorkIntervals as: 8:00 start, 9:00 stop, 9:00 start, 10:00 stop => No merged entries.
This happens regardless of the content of the merged resources, in this case two different types of leaves which should not be treated the same by nature (Paid/Unpaid).
When going though the leaves, we currently loop over the associated work intervals, this is part of the reason several leaves are processed as a single interval. The only reason we need the attendance interval is because some work entry types can take precedence over leaves (For instance a long term medical disability must supercede a public holiday).
In the interest of avoiding a change in the return type of the method '_get_interval_leave_work_entry_type' we instead rebuild the intervals with the bounds of the leave and the work entry type of the attendance.
opw-4193334
I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr
Forward-Port-Of: odoo/odoo#182273
This PR targets 18.0 and is part of the forward-port chain. Further PRs will be created up to master.
More info at https://github.com/odoo/odoo/wiki/Mergebot#forward-port
