mirror of
https://github.com/bringout/oca-ocb-hr.git
synced 2026-04-26 05:51:59 +02:00
19.0 vanilla
This commit is contained in:
parent
e1d89e11e3
commit
a1f02d8cc7
225 changed files with 2335 additions and 775 deletions
|
|
@ -825,8 +825,8 @@ class TestHrAttendanceOvertime(HttpCase):
|
|||
|
||||
def test_no_validation_extra_hours_change(self):
|
||||
"""
|
||||
In case of attendances requiring no validation, check that extra hours are not recomputed
|
||||
if the value is different from `validated_hours` (meaning it has been modified by the user).
|
||||
Check that manual edits are recomputed when updating another attendance,
|
||||
but flags the record as 'to_approve'
|
||||
"""
|
||||
self.company.attendance_overtime_validation = "no_validation"
|
||||
|
||||
|
|
@ -842,7 +842,7 @@ class TestHrAttendanceOvertime(HttpCase):
|
|||
self.assertAlmostEqual(attendance.overtime_hours, 1, 2)
|
||||
self.assertAlmostEqual(attendance.validated_overtime_hours, 1, 2)
|
||||
|
||||
attendance.linked_overtime_ids.manual_duration = previous = 0.5
|
||||
attendance.linked_overtime_ids.manual_duration = 0.5
|
||||
self.assertNotEqual(attendance.validated_overtime_hours, attendance.overtime_hours)
|
||||
|
||||
# Create another attendance for the same employee
|
||||
|
|
@ -851,7 +851,11 @@ class TestHrAttendanceOvertime(HttpCase):
|
|||
'check_in': datetime(2023, 1, 4, 8, 0),
|
||||
'check_out': datetime(2023, 1, 4, 18, 0)
|
||||
})
|
||||
self.assertEqual(attendance.validated_overtime_hours, previous, "Extra hours shouldn't be recomputed")
|
||||
# The hours will now be recomputed
|
||||
# But they should have the 'to_approve' status
|
||||
self.assertEqual(attendance.linked_overtime_ids.status, 'to_approve', "Record should be flagged for approval")
|
||||
self.assertAlmostEqual(attendance.linked_overtime_ids.duration, 1.0, 2, "Math should be reset to 1.0")
|
||||
self.assertEqual(attendance.validated_overtime_hours, 0.0, "Validated hours should be 0 until approved")
|
||||
|
||||
def _check_overtimes(self, overtimes, vals_list):
|
||||
self.assertEqual(len(overtimes), len(vals_list), "Wrong number of overtimes")
|
||||
|
|
|
|||
|
|
@ -112,15 +112,16 @@ class TestHrAttendanceOvertime(TransactionCase):
|
|||
def test_weekly_overtime(self):
|
||||
""" Test weekly overtime for the 40-hour rule """
|
||||
with freeze_time("2021-01-04"):
|
||||
# Week: Mon-Fri, 10 hours/day = 50 hours total (40 expected + 10 overtime at 200%)
|
||||
[
|
||||
self.env['hr.attendance'].create({
|
||||
'employee_id': self.employee.id, # This employee have a calendar with no lunch
|
||||
# Week: Mon-Fri, 10 hours/day = 50 hours total (10h daily OT + 8h weekly OT = 18h total)
|
||||
attendance_vals = [
|
||||
{
|
||||
'employee_id': self.employee.id,
|
||||
'check_in': datetime(2021, 1, day, 8, 0),
|
||||
'check_out': datetime(2021, 1, day, 18, 0)
|
||||
}) for day in range(4, 9) # Monday to Friday
|
||||
} for day in range(4, 9) # Monday to Friday
|
||||
]
|
||||
self.assertAlmostEqual(self.employee.total_overtime, 10, 2, msg="He should work from 8-16h so each day he did 2 hours of overtime")
|
||||
self.env['hr.attendance'].create(attendance_vals)
|
||||
self.assertAlmostEqual(self.employee.total_overtime, 18, 2, msg="He should work from 8-16h so each day he did 2 hours of overtime")
|
||||
|
||||
def test_multiple_attendances_same_day(self):
|
||||
""" Test multiple attendances in one day """
|
||||
|
|
|
|||
|
|
@ -477,8 +477,8 @@ class TestHrAttendanceUndertime(HttpCase):
|
|||
|
||||
def test_no_validation_extra_hours_change(self):
|
||||
"""
|
||||
In case of attendances requiring no validation, check that extra hours are not recomputed
|
||||
if the value is different from `validated_hours` (meaning it has been modified by the user).
|
||||
Check that manual edits are recomputed when updating another attendance,
|
||||
but flags the record as 'to_approve'.
|
||||
"""
|
||||
self.company.attendance_overtime_validation = "no_validation"
|
||||
|
||||
|
|
@ -494,7 +494,7 @@ class TestHrAttendanceUndertime(HttpCase):
|
|||
self.assertAlmostEqual(attendance.overtime_hours, -2, 2)
|
||||
self.assertAlmostEqual(attendance.validated_overtime_hours, -2, 2)
|
||||
|
||||
attendance.linked_overtime_ids.manual_duration = previous = -1.5
|
||||
attendance.linked_overtime_ids.manual_duration = -1.5
|
||||
self.assertNotEqual(attendance.validated_overtime_hours, attendance.overtime_hours)
|
||||
|
||||
# Create another attendance for the same employee
|
||||
|
|
@ -503,7 +503,11 @@ class TestHrAttendanceUndertime(HttpCase):
|
|||
'check_in': datetime(2023, 1, 4, 8, 0),
|
||||
'check_out': datetime(2023, 1, 4, 18, 0),
|
||||
})
|
||||
self.assertEqual(attendance.validated_overtime_hours, previous, "Extra hours shouldn't be recomputed")
|
||||
# The hours will now be recomputed
|
||||
# But they should have the 'to_approve' status
|
||||
self.assertEqual(attendance.linked_overtime_ids.status, 'to_approve', "Record should be flagged for approval")
|
||||
self.assertAlmostEqual(attendance.linked_overtime_ids.duration, -2.0, 2, "Math should be reset to -2.0")
|
||||
self.assertEqual(attendance.validated_overtime_hours, 0.0, "Validated hours should be 0 until approved")
|
||||
|
||||
def test_overtime_employee_tolerance(self):
|
||||
self.ruleset.rule_ids[0].employee_tolerance = 10 / 60
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue