2 In order to test hr_attendance module in OpenERP, I will first create new attendance reasons and perform Sign In/Sign Out operations.
5 I create a new employee "Mark Johnson".
7 !record {model: hr.employee, id: hr_employee_employee0}:
8 address_home_id: base.res_partner_address_1
9 company_id: base.main_company
12 user_id: base.user_root
15 I create a new attendance reason "Login" for Sign In.
17 !record {model: hr.action.reason, id: hr_action_reason_login0}:
21 I create second attendance reason "Logout" for Sign Out.
23 !record {model: hr.action.reason, id: hr_action_reason_logout0}:
27 Now, at the time of login, I create an attendance with "Sign In" action and proper reason.
29 !record {model: hr.attendance, id: hr_attendance_0}:
31 action_desc: 'hr_action_reason_login0'
32 employee_id: 'hr_employee_employee0'
33 name: !eval "'%s-01-01 19:08:08' %(datetime.now().year)"
35 I check that Employee state is "Present".
37 !assert {model: hr.employee, id: hr_employee_employee0}:
41 At the time of logout, I create an attendance with "Sign Out" action.
43 !record {model: hr.attendance, id: hr_attendance_1}:
45 employee_id: 'hr_employee_employee0'
46 name: !eval "'%s-01-01 19:10:55' %(datetime.now().year)"
48 I check that Employee state is Absent.
50 !assert {model: hr.employee, id: hr_employee_employee0}:
54 I will use "Sign In/Sign Out" wizard for attendances.
56 !record {model: hr.sign.in.out, id: hr_sign_in_out_markjohnson0}:
61 I click on "Sign In" button of this wizard to login.
63 !python {model: hr.sign.in.out}: |
64 obj_attendance = self.pool.get('hr.employee')
65 emp_id = obj_attendance.search(cr, uid, [('user_id', '=', uid), ('name', '=', "Mark Johnson")])
67 employee = obj_attendance.read(cr, uid, emp_id)[0]
68 self.write(cr, uid, [ref('hr_sign_in_out_markjohnson0')], {'name': employee['name'], 'state': employee['state'], 'emp_id': emp_id[0]})
69 self.si_check(cr, uid, [ref("hr_sign_in_out_markjohnson0")], {"active_id": ref("hr_employee_employee0")})
72 I check that Employee state is "Present".
74 !assert {model: hr.employee, id: hr_employee_employee0}:
78 I forgot to "Sign Out" Yesterday and want to sign in Today using This wizard.
80 !record {model: hr.sign.in.out, id: hr_sign_in_out_markjohnson0}:
84 I click on "Sign In" button of this wizard, this will Open a new form which ask for Last Sign Out date.
86 !python {model: hr.sign.in.out}: |
87 obj_attendance = self.pool.get('hr.employee')
88 emp_id = obj_attendance.search(cr, uid, [('user_id', '=', uid), ('name', '=', "Mark Johnson")])
90 employee = obj_attendance.read(cr, uid, emp_id)[0]
91 self.write(cr, uid, [ref('hr_sign_in_out_markjohnson0')], {'name': employee['name'], 'state': employee['state'], 'emp_id': emp_id[0]})
92 self.si_check(cr, uid, [ref("hr_sign_in_out_markjohnson0")])
94 I select Last Sign Out date.
96 !record {model: hr.sign.in.out.ask, id: hr_sign_in_out_ask_markjohnson0}:
97 last_time: !eval time.strftime('%Y-%m-%d %H:%M:%S')
100 Now I click on "Sign In" button of this wizard.
102 !python {model: hr.sign.in.out.ask}: |
103 obj_attendance = self.pool.get('hr.employee')
104 emp_id = obj_attendance.search(cr, uid, [('user_id', '=', uid), ('name', '=', "Mark Johnson")])
106 employee = obj_attendance.read(cr, uid, emp_id)[0]
107 self.write(cr, uid, [ref('hr_sign_in_out_ask_markjohnson0')], {'emp_id': emp_id[0]})
108 #self.sign_in(cr, uid, [ref("hr_sign_in_out_ask_markjohnson0")], {"active_ids": [ref("hr_attendance.menu_hr_attendance_sigh_in_out")]})
111 Finally i will check the state of the employee is present.
113 !record {model: hr.sign.in.out, id: hr_sign_in_out_markjohnson0}: