|
6 | 6 |
|
7 | 7 | from dateutil.relativedelta import relativedelta
|
8 | 8 |
|
9 |
| -from odoo.exceptions import UserError |
10 | 9 | from odoo.tests.common import TransactionCase
|
11 | 10 | from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT as DF
|
12 | 11 |
|
13 | 12 |
|
14 | 13 | class TestHrAttendanceTracking(TransactionCase):
|
15 |
| - def setUp(self): |
16 |
| - super(TestHrAttendanceTracking, self).setUp() |
17 |
| - self.hr_attendance = self.env["hr.attendance"] |
18 |
| - self.employee_01 = self.env["hr.employee"].create({"name": "Employee01"}) |
19 |
| - self.employee_02 = self.env["hr.employee"].create({"name": "Employee02"}) |
20 |
| - self.employee_03 = self.env["hr.employee"].create({"name": "Employee03"}) |
21 |
| - self.employee_04 = self.env["hr.employee"].create({"name": "Employee04"}) |
22 |
| - self.employee_05 = self.env["hr.employee"].create({"name": "Employee05"}) |
23 |
| - self.employee_06 = self.env["hr.employee"].create({"name": "Employee06"}) |
24 |
| - self.employee_07 = self.env["hr.employee"].create({"name": "Employee07"}) |
25 |
| - dti = datetime.now() |
26 |
| - self.att_test = self.hr_attendance.create( |
27 |
| - { |
28 |
| - "employee_id": self.employee_07.id, |
29 |
| - "check_in": dti.strftime(DF), |
30 |
| - } |
31 |
| - ) |
| 14 | + @classmethod |
| 15 | + def setUpClass(cls): |
| 16 | + super().setUpClass() |
| 17 | + cls.hr_attendance = cls.env["hr.attendance"] |
| 18 | + cls.employee_01 = cls.env["hr.employee"].create({"name": "Employee01"}) |
| 19 | + cls.employee_02 = cls.env["hr.employee"].create({"name": "Employee02"}) |
| 20 | + cls.employee_03 = cls.env["hr.employee"].create({"name": "Employee03"}) |
| 21 | + cls.employee_04 = cls.env["hr.employee"].create({"name": "Employee04"}) |
| 22 | + cls.employee_05 = cls.env["hr.employee"].create({"name": "Employee05"}) |
| 23 | + cls.employee_06 = cls.env["hr.employee"].create({"name": "Employee06"}) |
32 | 24 |
|
33 | 25 | def test_attendance_edit_01(self):
|
34 | 26 | # We can't check kiosk and check-in/check-out form
|
@@ -151,17 +143,3 @@ def test_attendance_edit_07(self):
|
151 | 143 | False,
|
152 | 144 | "Use case 7: Wrong value, time not changed manually.",
|
153 | 145 | )
|
154 |
| - |
155 |
| - def test_attendance_edit_08(self): |
156 |
| - # Use case 8: |
157 |
| - # Trying to create a check-in with an existing one |
158 |
| - dti = datetime.now() + relativedelta(minutes=15) |
159 |
| - with self.assertRaises(UserError) as e: |
160 |
| - self.att_test.create( |
161 |
| - {"employee_id": self.employee_07.id, "check_in": dti.strftime(DF)} |
162 |
| - ) |
163 |
| - self.assertEqual( |
164 |
| - e.exception.args[0], |
165 |
| - "It is not possible to register a new entry because there is already " |
166 |
| - "an existing one.", |
167 |
| - ) |
0 commit comments