[MERGE] merge with latest stable
[odoo/odoo.git] / addons / hr_attendance / test / test_hr_attendance.yml
1 -
2   In order to test hr_attendance module in OpenERP,  I will first create new attendance reasons and perform Sign In/Sign Out operations.
3
4 -
5   I create a new employee "Mark Johnson".
6 -
7   !record {model: hr.employee, id: hr_employee_employee0}:
8     address_home_id: base.res_partner_address_1
9     company_id: base.main_company
10     gender: male
11     name: Mark Johnson
12     user_id: base.user_root
13
14 -
15   I create a new attendance reason "Login" for Sign In.
16 -
17   !record {model: hr.action.reason, id: hr_action_reason_login0}:
18     name: Login
19     action_type: sign_in
20 -
21   I create second attendance reason "Logout" for Sign Out.
22 -
23   !record {model: hr.action.reason, id: hr_action_reason_logout0}:
24     name: Logout
25     action_type: sign_out
26 -
27   Now, at the time of login, I create an attendance with "Sign In" action and proper reason.
28 -
29   !record {model: hr.attendance, id: hr_attendance_0}:
30     action: sign_in
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)"
34 -
35   I check that Employee state is "Present".
36 -
37   !assert {model: hr.employee, id: hr_employee_employee0}:
38     - state == 'present'
39
40 -
41   At the time of logout, I create an attendance with "Sign Out" action.
42 -
43   !record {model: hr.attendance, id: hr_attendance_1}:
44     action: sign_out
45     employee_id: 'hr_employee_employee0'
46     name: !eval "'%s-01-01 19:10:55' %(datetime.now().year)"
47 -
48   I check that Employee state is Absent.
49 -
50   !assert {model: hr.employee, id: hr_employee_employee0}:
51     - state == 'absent'
52
53 -
54   I will use "Sign In/Sign Out" wizard for attendances.
55 -
56   !record {model: hr.sign.in.out, id: hr_sign_in_out_markjohnson0}:
57     name: Mark Johnson
58     state: absent
59
60 -
61   I click on "Sign In" button of this wizard to login.
62 -
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")])
66     if emp_id:
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")})
70
71 -
72   I check that Employee state is "Present".
73 -
74   !assert {model: hr.employee, id: hr_employee_employee0}:
75     - state == 'present'
76
77 -
78   I forgot to "Sign Out" Yesterday and want to sign in Today using This wizard.
79 -
80   !record {model: hr.sign.in.out, id: hr_sign_in_out_markjohnson0}:
81     name: Mark Johnson
82     state: present
83 -
84   I click on "Sign In" button of this wizard, this will Open a new form which ask for Last Sign Out date.
85 -
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")])
89     if emp_id:
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")])
93 -
94   I select Last Sign Out date.
95 -
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')
98     name: Mark Johnson
99 -
100   Now I click on "Sign In" button of this wizard.
101 -
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")])
105     if emp_id:
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")]})
109
110 -
111   Finally i will check the state of the employee is present.
112 -
113   !record {model: hr.sign.in.out, id: hr_sign_in_out_markjohnson0}:
114     name: Mark Johnson
115     state: present
116