| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
from datetime import datetime |
| 5 |
|
| 6 |
from odoo.tests import tagged |
| 7 |
from odoo.addons.hr_timesheet.tests.test_timesheet import TestCommonTimesheet |
| 8 |
|
| 9 |
@tagged('post_install', '-at_install') |
| 10 |
class TestTimesheetAttendance(TestCommonTimesheet): |
| 11 |
@classmethod |
| 12 |
def setUpClass(cls): |
| 13 |
super().setUpClass() |
| 14 |
cls.env['hr.attendance'].create({ |
| 15 |
'employee_id': cls.empl_employee.id, |
| 16 |
'check_in': datetime(2022, 2, 9, 8, 0), |
| 17 |
'check_out': datetime(2022, 2, 9, 16, 0), |
| 18 |
}) |
| 19 |
|
| 20 |
def test_timesheet_attendance_report(self): |
| 21 |
self.env['account.analytic.line'].with_user(self.user_employee).create({ |
| 22 |
'name': 'Test timesheet 1', |
| 23 |
'project_id': self.project_customer.id, |
| 24 |
'unit_amount': 6.0, |
| 25 |
'date': datetime(2022, 2, 9), |
| 26 |
}) |
| 27 |
total_timesheet, total_attendance = self.env['hr.timesheet.attendance.report']._read_group( |
| 28 |
[('employee_id', '=', self.empl_employee.id), |
| 29 |
('date', '>=', datetime(2022, 2, 9, 8, 0)), ('date', '<=', datetime(2022, 2, 9, 16, 0))], |
| 30 |
aggregates=['total_timesheet:sum', 'total_attendance:sum'], |
| 31 |
)[0] |
| 32 |
self.assertEqual(total_timesheet, 6.0, "Total timesheet in report should be 4.0") |
| 33 |
self.assertEqual(total_attendance, 7.0, "Total attendance in report should be 8.0") |
| 34 |
self.assertEqual(total_attendance - total_timesheet, 1) |