Debian Codegraph @

addons/hr_holidays/tests/test_past_accruals.py

raw symbols SCIP
1 # Part of Odoo. See LICENSE file for full copyright and licensing details.
2 from datetime import date
3 from freezegun import freeze_time
4
5 from odoo.tests import tagged
6
7 from odoo.addons.hr_holidays.tests.common import TestHrHolidaysCommon
8
9
10 @tagged('post_install', '-at_install', 'accruals')
11 class TestAccrualAllocations(TestHrHolidaysCommon):
12 @classmethod
13 def setUpClass(cls):
14 super(TestAccrualAllocations, cls).setUpClass()
15 cls.leave_type = cls.env['hr.leave.type'].create({
16 'name': 'Accrual Time Off',
17 'time_type': 'leave',
18 'requires_allocation': True,
19 'allocation_validation_type': 'no',
20 })
21 cls.accrual_plan = cls.env['hr.leave.accrual.plan'].with_context(tracking_disable=True).create({
22 'name': 'Test Seniority Plan',
23 'level_ids': [
24 (0, 0, {
25 'milestone_date': 'after',
26 'start_count': 1,
27 'start_type': 'day',
28 'added_value': 1,
29 'added_value_type': 'day',
30 'frequency': 'yearly',
31 'cap_accrued_time': True,
32 'maximum_leave': 10000,
33 }),
34 (0, 0, {
35 'milestone_date': 'after',
36 'start_count': 4,
37 'start_type': 'year',
38 'added_value': 1,
39 'added_value_type': 'day',
40 'frequency': 'yearly',
41 'cap_accrued_time': True,
42 'maximum_leave': 10000,
43 }),
44 (0, 0, {
45 'milestone_date': 'after',
46 'start_count': 8,
47 'start_type': 'year',
48 'added_value': 1,
49 'added_value_type': 'day',
50 'frequency': 'yearly',
51 'cap_accrued_time': True,
52 'maximum_leave': 10000,
53 }),
54 ]
55 })
56
57 def _test_past_accrual(self):
58 with freeze_time("2023-12-01"):
59 allocation = self.env['hr.leave.allocation'].create({
60 'employee_id': self.employee_emp_id,
61 'allocation_type': 'accrual',
62 'accrual_plan_id': self.accrual_plan.id,
63 'holiday_status_id': self.leave_type.id,
64 'date_from': date(2000, 1, 1),
65 'number_of_days': 0,
66 })
67
68 allocation._process_accrual_plans()
69
70 self.assertEqual(allocation.number_of_days, 0)