diff --git a/addons/project_timesheet_holidays/models/hr_holidays.py b/addons/project_timesheet_holidays/models/hr_holidays.py index 2717a4eab59..a2d2457f573 100644 --- a/addons/project_timesheet_holidays/models/hr_holidays.py +++ b/addons/project_timesheet_holidays/models/hr_holidays.py @@ -61,5 +61,6 @@ class Holidays(models.Model): def action_refuse(self): """ Remove the timesheets linked to the refused holidays """ result = super(Holidays, self).action_refuse() + self.mapped('timesheet_ids').write({'holiday_id': False}) self.mapped('timesheet_ids').unlink() return result diff --git a/addons/project_timesheet_holidays/tests/test_timesheet_holidays.py b/addons/project_timesheet_holidays/tests/test_timesheet_holidays.py index f49cf00ed14..f98817fdeec 100644 --- a/addons/project_timesheet_holidays/tests/test_timesheet_holidays.py +++ b/addons/project_timesheet_holidays/tests/test_timesheet_holidays.py @@ -72,6 +72,10 @@ class TestTimesheetHolidays(TestTimesheet): holiday.sudo().action_validate() self.assertEquals(len(holiday.timesheet_ids), number_of_days, 'Number of generated timesheets should be the same as the leave duration (1 per day)') + # manager refuse the leave + holiday.sudo().action_refuse() + self.assertEquals(len(holiday.timesheet_ids), 0, 'Number of linked timesheets should be zero, since the leave is refused.') + def test_validate_without_timesheet(self): # employee creates a leave request number_of_days = (self.leave_end_datetime - self.leave_start_datetime).days