Skip to content
Snippets Groups Projects
Commit 54cdc843 authored by Kevin Baptiste's avatar Kevin Baptiste
Browse files

[FIX] hr_holidays_attendance: grant back overtime on leave deletion


The linked overtime record was not deleted when deleting a time off.
Meaning that those hours were lost.

task-3097259

closes odoo/odoo#107713

Signed-off-by: default avatarKevin Baptiste <kba@odoo.com>
parent d7c9521d
No related branches found
No related tags found
No related merge requests found
......@@ -100,3 +100,8 @@ class HRLeave(models.Model):
employee_dates[leave.employee_id].add(self.env['hr.attendance']._get_day_start_and_day(leave.employee_id, leave.date_from + timedelta(days=d)))
if employee_dates:
self.env['hr.attendance']._update_overtime(employee_dates)
def unlink(self):
# TODO master change to ondelete
self.sudo().overtime_id.unlink()
return super().unlink()
......@@ -134,6 +134,11 @@ class TestHolidaysOvertime(TransactionCase):
self.assertTrue(leave.overtime_id.exists(), "Overtime should be created")
self.assertEqual(self.employee.total_overtime, 0)
overtime = leave.overtime_id
leave.unlink()
self.assertFalse(overtime.exists(), "Overtime should be deleted along with the leave")
self.assertEqual(self.employee.total_overtime, 8)
def test_leave_check_overtime_write(self):
self.new_attendance(check_in=datetime(2021, 1, 2, 8), check_out=datetime(2021, 1, 2, 16))
self.new_attendance(check_in=datetime(2021, 1, 3, 8), check_out=datetime(2021, 1, 3, 16))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment