[FIX] resource : fix traceback in _get_attendance_intervals_days_data with adjacent attendances

----------------------Issue--------------------------
When calling get_work_duration_data on a calendar that contains adjacent calendar attendances,
we get a traceback in the method _get_attendance_intervals_days_data.
This is due to the fact that adjacent attendances (like 09:00 -> 13:00, 13:00 -> 17:00) will get merged into one single interval.
Which will generate an attendance interval with multiple resource.calendar.attendance records associated with it.

----------------Steps to reproduce-------------------
1) Create a Calendar
2) Create for a same day 2 attendances going from 09:00 to 13:00 and another going from 13:00 to 17:00 3) Try creating a time-off for that day
3) Associate that calendar with an employee
4) Try creating a time off on the day where we have adjacent attendances
---------------------Fix-----------------------------
Adapt _get_attendance_intervals_days_data to handle attendance intervals associated with multiple resource.calendar.attendance

task-3615723

closes odoo/odoo#144036

Signed-off-by: Bertrand Dossogne (bedo) <bedo@odoo.com>
This commit is contained in:
jugj-odoo
2023-12-06 09:53:19 +00:00
parent 7a8c0b0091
commit 8b978ab01d
3 changed files with 17 additions and 1 deletions
+8
View File
@@ -61,6 +61,8 @@ class TestResourceCommon(TransactionCase):
cls.calendar_paul = cls._define_calendar('Morning and evening shifts', sum([((2, 7, i, 0.5), (10, 16, i, 0.5)) for i in range(5)], ()), 'Brazil/DeNoronha')
cls.calendar_bob = cls._define_calendar('Calendar with adjacent attendances', sum([((8, 12, i, 0.5), (12, 16, i, 0.5)) for i in range(5)], ()), 'Europe/Brussels')
# Employee is linked to a resource.resource via resource.mixin
cls.jean = cls.env['resource.test'].create({
'name': 'Jean',
@@ -84,6 +86,12 @@ class TestResourceCommon(TransactionCase):
'resource_calendar_id': cls.calendar_paul.id,
})
cls.bob = cls.env['resource.test'].create({
'name': 'Bob',
'resource_calendar_id': cls.calendar_bob.id,
})
cls.two_weeks_resource = cls._define_calendar_2_weeks(
'Two weeks resource',
[