Skip to content

Commit 1ede0a1

Browse files
committed
[FIX] hr_holidays: Test failing with dynamic dates
test_calendar_event_create_access_rights uses today as the base for the dates of an holiday request which breaks starting from 17.0 when it generates dates overlapping a weekend. This commit makes the test use a static date instead task-5136270
1 parent 862f404 commit 1ede0a1

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

addons/hr_holidays/tests/test_leave_requests.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1658,14 +1658,15 @@ def test_calendar_event_create_access_rights(self):
16581658
self.employee_emp.user_id = user_portal
16591659

16601660
# As a manager, create a leave request for the employee linked to a portal user
1661-
leave = self.env['hr.leave'].with_user(self.user_hrmanager_id).create({
1662-
'name': 'Holiday Request',
1663-
'employee_id': self.employee_emp_id,
1664-
'holiday_status_id': self.holidays_type_1.id,
1665-
'date_from': (datetime.today() - relativedelta(days=1)),
1666-
'date_to': datetime.today(),
1667-
'number_of_days': 1,
1668-
})
1661+
with freeze_time('2025, 1, 8'):
1662+
leave = self.env['hr.leave'].with_user(self.user_hrmanager_id).create({
1663+
'name': 'Holiday Request',
1664+
'employee_id': self.employee_emp_id,
1665+
'holiday_status_id': self.holidays_type_1.id,
1666+
'request_date_from': (datetime.today() - relativedelta(days=7)),
1667+
'request_date_to': datetime.today(),
1668+
'number_of_days': 1,
1669+
})
16691670

16701671
# Assert the employee cannot approve his own leave request
16711672
with self.assertRaises(AccessError):

0 commit comments

Comments
 (0)