diff --git a/addons/project_timesheet_holidays/models/project_task.py b/addons/project_timesheet_holidays/models/project_task.py index fac32a30904..660ad45e52a 100644 --- a/addons/project_timesheet_holidays/models/project_task.py +++ b/addons/project_timesheet_holidays/models/project_task.py @@ -32,7 +32,7 @@ class Task(models.Model): ['timesheet_task_ids:array_agg(timesheet_task_id)'], [], ) - timeoff_task_ids = leave_type_read_group[0]['timesheet_task_ids'] if leave_type_read_group else [] + timeoff_task_ids = leave_type_read_group[0]['timesheet_task_ids'] if leave_type_read_group[0]['timesheet_task_ids'] else [] if self.env.company.leave_timesheet_task_id: timeoff_task_ids.append(self.env.company.leave_timesheet_task_id.id) if operator == '!=': diff --git a/addons/project_timesheet_holidays/tests/test_timesheet_global_time_off.py b/addons/project_timesheet_holidays/tests/test_timesheet_global_time_off.py index 0112b111992..814f35d9903 100644 --- a/addons/project_timesheet_holidays/tests/test_timesheet_global_time_off.py +++ b/addons/project_timesheet_holidays/tests/test_timesheet_global_time_off.py @@ -175,3 +175,12 @@ class TestTimesheetGlobalTimeOff(common.TransactionCase): # The standard calendar is for 8 hours/day from 8 to 12 and from 13 to 17. # So we need to check that the timesheets don't have more than 8 hours per day. self.assertEqual(leave_task.effective_hours, 80) + + def test_search_is_timeoff_task(self): + """ Test the search method on is_timeoff_task + with and without any hr.leave.type with timesheet_task_id defined""" + leaves_types_with_task_id = self.env['hr.leave.type'].search([('timesheet_task_id', '!=', False)]) + self.env['project.task'].search([('is_timeoff_task', '!=', False)]) + + leaves_types_with_task_id.write({'timesheet_task_id': False}) + self.env['project.task'].search([('is_timeoff_task', '!=', False)])