[FIX] project_timesheet_holidays: Fix traceback when no timesheet_task_id is found.
-steps to reproduce: do a search in project.task on is_timeoff_task when no timesheet_task_id is defined on any hr.leave_type. This will trigger the _search_is_timeoff_task method -before this commit: crash when no leave_type with timesheet_task_id is found -after this commit: creation of an empty list as expected opw-3086486 closes odoo/odoo#110091 X-original-commit: b98949b1cb85514ee5a56ff1a5860591c10b0994 Signed-off-by: Xavier Bol (xbo) <xbo@odoo.com>
This commit is contained in:
@@ -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 == '!=':
|
||||
|
||||
@@ -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)])
|
||||
|
||||
Reference in New Issue
Block a user