From b600373abbba2b1746b6b60ea23f4b5da0529e5b Mon Sep 17 00:00:00 2001 From: Kevin Baptiste Date: Fri, 17 Dec 2021 09:59:14 +0000 Subject: [PATCH] [FIX] hr_holidays: fix accrual test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The test `test_unused_accrual_postponed` was expecting at least 25 holidays to be accrued, but started failing around mid-December. closes odoo/odoo#81592 X-original-commit: c2865b7f5b654a61d4b2690133797aa39712b00d Signed-off-by: Xavier Dollé (xdo) Signed-off-by: Christophe Monniez (moc) --- .../tests/test_accrual_allocations.py | 90 ++++++++++--------- 1 file changed, 46 insertions(+), 44 deletions(-) diff --git a/addons/hr_holidays/tests/test_accrual_allocations.py b/addons/hr_holidays/tests/test_accrual_allocations.py index 6be3225a471..f5c2beeefa2 100644 --- a/addons/hr_holidays/tests/test_accrual_allocations.py +++ b/addons/hr_holidays/tests/test_accrual_allocations.py @@ -498,28 +498,29 @@ class TestAccrualAllocations(TestHrHolidaysCommon): def test_unused_accrual_lost(self): #1 accrual with 2 levels and level transition immediately - accrual_plan = self.env['hr.leave.accrual.plan'].with_context(tracking_disable=True).create({ - 'name': 'Accrual Plan For Test', - 'level_ids': [(0, 0, { - 'start_count': 1, - 'start_type': 'day', - 'added_value': 1, - 'added_value_type': 'days', - 'frequency': 'daily', - 'maximum_leave': 1, - 'action_with_unused_accruals': 'lost', - })], - }) - allocation = self.env['hr.leave.allocation'].with_user(self.user_hrmanager_id).with_context(tracking_disable=True).create({ - 'name': 'Accrual allocation for employee', - 'accrual_plan_id': accrual_plan.id, - 'employee_id': self.employee_emp.id, - 'holiday_status_id': self.leave_type.id, - 'number_of_days': 10, - 'allocation_type': 'accrual', - }) - allocation.action_confirm() - allocation.action_validate() + with freeze_time('2021-09-01'): + accrual_plan = self.env['hr.leave.accrual.plan'].with_context(tracking_disable=True).create({ + 'name': 'Accrual Plan For Test', + 'level_ids': [(0, 0, { + 'start_count': 1, + 'start_type': 'day', + 'added_value': 1, + 'added_value_type': 'days', + 'frequency': 'daily', + 'maximum_leave': 1, + 'action_with_unused_accruals': 'lost', + })], + }) + allocation = self.env['hr.leave.allocation'].with_user(self.user_hrmanager_id).with_context(tracking_disable=True).create({ + 'name': 'Accrual allocation for employee', + 'accrual_plan_id': accrual_plan.id, + 'employee_id': self.employee_emp.id, + 'holiday_status_id': self.leave_type.id, + 'number_of_days': 10, + 'allocation_type': 'accrual', + }) + allocation.action_confirm() + allocation.action_validate() with freeze_time('2022-01-01'): allocation._update_accrual() @@ -528,28 +529,29 @@ class TestAccrualAllocations(TestHrHolidaysCommon): def test_unused_accrual_postponed(self): # 1 accrual with 2 levels and level transition after # This also tests retroactivity - accrual_plan = self.env['hr.leave.accrual.plan'].with_context(tracking_disable=True).create({ - 'name': 'Accrual Plan For Test', - 'level_ids': [(0, 0, { - 'start_count': 1, - 'start_type': 'day', - 'added_value': 1, - 'added_value_type': 'days', - 'frequency': 'daily', - 'maximum_leave': 25, - 'action_with_unused_accruals': 'postponed', - })], - }) - allocation = self.env['hr.leave.allocation'].with_user(self.user_hrmanager_id).with_context(tracking_disable=True).create({ - 'name': 'Accrual allocation for employee', - 'accrual_plan_id': accrual_plan.id, - 'employee_id': self.employee_emp.id, - 'holiday_status_id': self.leave_type.id, - 'number_of_days': 10, - 'allocation_type': 'accrual', - }) - allocation.action_confirm() - allocation.action_validate() + with freeze_time('2021-09-01'): + accrual_plan = self.env['hr.leave.accrual.plan'].with_context(tracking_disable=True).create({ + 'name': 'Accrual Plan For Test', + 'level_ids': [(0, 0, { + 'start_count': 1, + 'start_type': 'day', + 'added_value': 1, + 'added_value_type': 'days', + 'frequency': 'daily', + 'maximum_leave': 25, + 'action_with_unused_accruals': 'postponed', + })], + }) + allocation = self.env['hr.leave.allocation'].with_user(self.user_hrmanager_id).with_context(tracking_disable=True).create({ + 'name': 'Accrual allocation for employee', + 'accrual_plan_id': accrual_plan.id, + 'employee_id': self.employee_emp.id, + 'holiday_status_id': self.leave_type.id, + 'number_of_days': 10, + 'allocation_type': 'accrual', + }) + allocation.action_confirm() + allocation.action_validate() with freeze_time('2022-01-01'): allocation._update_accrual()