[NEW] hr_attendance_work_entry: for Odoo 13

This commit is contained in:
Jared Kipe
2020-09-18 11:28:39 -07:00
committed by Leo Pinedo
parent ace8808db9
commit 98c6ad8f3c
9 changed files with 180 additions and 0 deletions

View File

@@ -0,0 +1 @@
from . import test_attendance_work_type

View File

@@ -0,0 +1,47 @@
from odoo.tests import common
class TestAttendanceWorkType(common.TransactionCase):
def setUp(self):
super().setUp()
self.employee = self.env.ref('hr.employee_hne')
self.default_work_type = self.env.ref('hr_attendance_work_entry.work_input_attendance')
def test_01_work_type(self):
attendance = self.env['hr.attendance'].create({
'employee_id': self.employee.id,
'check_in': '2020-01-06 10:00:00', # Monday
'check_out': '2020-01-06 19:00:00',
})
self.assertTrue(attendance.work_type_id)
self.assertEqual(attendance.work_type_id, self.default_work_type)
def test_11_employee_clock_in(self):
self.assertEqual(self.employee.attendance_state, 'checked_out')
attendance = self.employee._attendance_action_change()
self.assertEqual(attendance.work_type_id, self.default_work_type)
self.assertEqual(self.employee.attendance_state, 'checked_in')
# check out
self.employee._attendance_action_change()
self.assertEqual(self.employee.attendance_state, 'checked_out')
def test_12_employee_clock_in_break(self):
# check in with non-standard work type
break_type = self.env['hr.work.entry.type'].create({
'name': 'Test Break',
'code': 'TESTBREAK',
'allow_attendance': True,
'attendance_state': 'break',
})
self.employee = self.employee.with_context(work_type_id=break_type.id)
attendance = self.employee._attendance_action_change()
self.assertEqual(attendance.work_type_id, break_type)
self.assertEqual(self.employee.attendance_state, 'break')
# check back in immediately with default
self.employee = self.employee.with_context(work_type_id=self.default_work_type.id)
attendance = self.employee._attendance_action_change()
self.assertEqual(attendance.work_type_id, self.default_work_type)
self.assertEqual(attendance.work_type_id.attendance_state, 'checked_in')
self.assertEqual(self.employee.attendance_state, 'checked_in')