[MERGE] hr_attendance: clean yml tests
bzr revid: rco@openerp.com-20111221131836-x3kge3d05odgubu9
This commit is contained in:
commit
b09f04b900
|
@ -47,8 +47,9 @@ actions(Sign in/Sign out) performed by them.
|
|||
'wizard/hr_attendance_sign_in_out_view.xml',
|
||||
],
|
||||
'demo_xml': ['hr_attendance_demo.xml'],
|
||||
'test': ['test/test_hr_attendance.yml',
|
||||
'test/hr_attendance_report.yml'
|
||||
'test': [
|
||||
'test/attendance_process.yml',
|
||||
'test/hr_attendance_report.yml',
|
||||
],
|
||||
'installable': True,
|
||||
'active': False,
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
-
|
||||
In order to test attendance process in OpenERP, at the time of login, I use "Sign In/Sign Out" wizard for attendances.
|
||||
-
|
||||
!record {model: hr.sign.in.out, id: employee_sign_in}:
|
||||
name: Antoine Philippe
|
||||
state: absent
|
||||
-
|
||||
I click on this wizard to login.
|
||||
-
|
||||
!python {model: hr.sign.in.out}: |
|
||||
obj_attendance = self.pool.get('hr.employee')
|
||||
emp_ids = obj_attendance.search(cr, uid, [('user_id', '=', uid), ('name', '=', "Antoine Philippe")])
|
||||
if emp_ids:
|
||||
employee = obj_attendance.read(cr, uid, emp_ids)[0]
|
||||
self.write(cr, uid, [ref('employee_sign_in')], {'name': employee['name'], 'state': employee['state'], 'emp_id': emp_ids[0]})
|
||||
self.si_check(cr, uid, [ref("employee_sign_in")])
|
||||
-
|
||||
I check that Employee is "Present".
|
||||
-
|
||||
!assert {model: hr.employee, id: hr.employee3, severity: error, string: Employee should be in present state}:
|
||||
- state == 'present'
|
||||
-
|
||||
I click on "Sign In" button of this wizard, this will Open a new form which ask for Last Sign Out date.
|
||||
-
|
||||
!python {model: hr.sign.in.out}: |
|
||||
obj_attendance = self.pool.get('hr.employee')
|
||||
emp_ids = obj_attendance.search(cr, uid, [('user_id', '=', uid), ('name', '=', "Antoine Philippe")])
|
||||
if emp_ids:
|
||||
employee = obj_attendance.read(cr, uid, emp_ids)[0]
|
||||
self.write(cr, uid, [ref('employee_sign_in')], {'name': employee['name'], 'state': employee['state'], 'emp_id': emp_ids[0]})
|
||||
self.si_check(cr, uid, [ref("employee_sign_in")])
|
||||
-
|
||||
I select Last Sign Out date.
|
||||
-
|
||||
!record {model: hr.sign.in.out.ask, id: hr_sign_in_out_ask_Antoine_Philippe}:
|
||||
last_time: !eval time.strftime('%Y-%m-%d %H:%M:%S')
|
||||
name: Antoine Philippe
|
||||
-
|
||||
Now I click on "Sign In" button of this wizard.
|
||||
-
|
||||
!python {model: hr.sign.in.out.ask}: |
|
||||
obj_attendance = self.pool.get('hr.employee')
|
||||
emp_ids = obj_attendance.search(cr, uid, [('user_id', '=', uid), ('name', '=', "Antoine Philippe")])
|
||||
if emp_ids:
|
||||
employee = obj_attendance.read(cr, uid, emp_ids)[0]
|
||||
self.write(cr, uid, [ref('hr_sign_in_out_ask_Antoine_Philippe')], {'emp_id': emp_ids[0]})
|
||||
-
|
||||
Finally i check the employee is present.
|
||||
-
|
||||
!assert {model: hr.employee, id: hr.employee3, severity: error, string: Employee should be in present state}:
|
||||
- state == 'present'
|
|
@ -2,19 +2,16 @@
|
|||
Print the HR Attendance Report By Month through the wizard
|
||||
-
|
||||
!python {model: hr.employee}: |
|
||||
import time
|
||||
ctx={}
|
||||
ctx.update({'model': 'hr.employee','active_ids': [ref('hr.employee1'),ref('hr.employee2'),ref('hr.employee3')]})
|
||||
data_dict = {}
|
||||
from tools import test_reports
|
||||
ctx = {'model': 'hr.employee','active_ids': [ref('hr.employee1'),ref('hr.employee2'),ref('hr.employee3')]}
|
||||
data_dict = {}
|
||||
test_reports.try_report_action(cr, uid, 'action_hr_attendance_month',wiz_data=data_dict, context=ctx, our_module='hr_attendance')
|
||||
-
|
||||
Print HR Attendance Error Report through the wizard
|
||||
-
|
||||
!python {model: hr.employee}: |
|
||||
import time
|
||||
ctx={}
|
||||
ctx.update({'model': 'hr.employee','active_ids': [ref('hr.employee1')]})
|
||||
data_dict = {'init_date': time.strftime('%Y-01-01')}
|
||||
from tools import test_reports
|
||||
ctx = {'model': 'hr.employee','active_ids': [ref('hr.employee1')]}
|
||||
data_dict = {'init_date': time.strftime('%Y-01-01')}
|
||||
test_reports.try_report_action(cr, uid, 'action_hr_attendance_error',wiz_data=data_dict, context=ctx, our_module='hr_attendance')
|
||||
|
|
|
@ -1,116 +0,0 @@
|
|||
-
|
||||
In order to test hr_attendance module in OpenERP, I will first create new attendance reasons and perform Sign In/Sign Out operations.
|
||||
|
||||
-
|
||||
I create a new employee "Mark Johnson".
|
||||
-
|
||||
!record {model: hr.employee, id: hr_employee_employee0}:
|
||||
address_home_id: base.res_partner_address_1
|
||||
company_id: base.main_company
|
||||
gender: male
|
||||
name: Mark Johnson
|
||||
user_id: base.user_root
|
||||
|
||||
-
|
||||
I create a new attendance reason "Login" for Sign In.
|
||||
-
|
||||
!record {model: hr.action.reason, id: hr_action_reason_login0}:
|
||||
name: Login
|
||||
action_type: sign_in
|
||||
-
|
||||
I create second attendance reason "Logout" for Sign Out.
|
||||
-
|
||||
!record {model: hr.action.reason, id: hr_action_reason_logout0}:
|
||||
name: Logout
|
||||
action_type: sign_out
|
||||
-
|
||||
Now, at the time of login, I create an attendance with "Sign In" action and proper reason.
|
||||
-
|
||||
!record {model: hr.attendance, id: hr_attendance_0}:
|
||||
action: sign_in
|
||||
action_desc: 'hr_action_reason_login0'
|
||||
employee_id: 'hr_employee_employee0'
|
||||
name: !eval "'%s-01-01 19:08:08' %(datetime.now().year)"
|
||||
-
|
||||
I check that Employee state is "Present".
|
||||
-
|
||||
!assert {model: hr.employee, id: hr_employee_employee0}:
|
||||
- state == 'present'
|
||||
|
||||
-
|
||||
At the time of logout, I create an attendance with "Sign Out" action.
|
||||
-
|
||||
!record {model: hr.attendance, id: hr_attendance_1}:
|
||||
action: sign_out
|
||||
employee_id: 'hr_employee_employee0'
|
||||
name: !eval "'%s-01-01 19:10:55' %(datetime.now().year)"
|
||||
-
|
||||
I check that Employee state is Absent.
|
||||
-
|
||||
!assert {model: hr.employee, id: hr_employee_employee0}:
|
||||
- state == 'absent'
|
||||
|
||||
-
|
||||
I will use "Sign In/Sign Out" wizard for attendances.
|
||||
-
|
||||
!record {model: hr.sign.in.out, id: hr_sign_in_out_markjohnson0}:
|
||||
name: Mark Johnson
|
||||
state: absent
|
||||
|
||||
-
|
||||
I click on "Sign In" button of this wizard to login.
|
||||
-
|
||||
!python {model: hr.sign.in.out}: |
|
||||
obj_attendance = self.pool.get('hr.employee')
|
||||
emp_id = obj_attendance.search(cr, uid, [('user_id', '=', uid), ('name', '=', "Mark Johnson")])
|
||||
if emp_id:
|
||||
employee = obj_attendance.read(cr, uid, emp_id)[0]
|
||||
self.write(cr, uid, [ref('hr_sign_in_out_markjohnson0')], {'name': employee['name'], 'state': employee['state'], 'emp_id': emp_id[0]})
|
||||
self.si_check(cr, uid, [ref("hr_sign_in_out_markjohnson0")], {"active_id": ref("hr_employee_employee0")})
|
||||
|
||||
-
|
||||
I check that Employee state is "Present".
|
||||
-
|
||||
!assert {model: hr.employee, id: hr_employee_employee0}:
|
||||
- state == 'present'
|
||||
|
||||
-
|
||||
I forgot to "Sign Out" Yesterday and want to sign in Today using This wizard.
|
||||
-
|
||||
!record {model: hr.sign.in.out, id: hr_sign_in_out_markjohnson0}:
|
||||
name: Mark Johnson
|
||||
state: present
|
||||
-
|
||||
I click on "Sign In" button of this wizard, this will Open a new form which ask for Last Sign Out date.
|
||||
-
|
||||
!python {model: hr.sign.in.out}: |
|
||||
obj_attendance = self.pool.get('hr.employee')
|
||||
emp_id = obj_attendance.search(cr, uid, [('user_id', '=', uid), ('name', '=', "Mark Johnson")])
|
||||
if emp_id:
|
||||
employee = obj_attendance.read(cr, uid, emp_id)[0]
|
||||
self.write(cr, uid, [ref('hr_sign_in_out_markjohnson0')], {'name': employee['name'], 'state': employee['state'], 'emp_id': emp_id[0]})
|
||||
self.si_check(cr, uid, [ref("hr_sign_in_out_markjohnson0")])
|
||||
-
|
||||
I select Last Sign Out date.
|
||||
-
|
||||
!record {model: hr.sign.in.out.ask, id: hr_sign_in_out_ask_markjohnson0}:
|
||||
last_time: !eval time.strftime('%Y-%m-%d %H:%M:%S')
|
||||
name: Mark Johnson
|
||||
-
|
||||
Now I click on "Sign In" button of this wizard.
|
||||
-
|
||||
!python {model: hr.sign.in.out.ask}: |
|
||||
obj_attendance = self.pool.get('hr.employee')
|
||||
emp_id = obj_attendance.search(cr, uid, [('user_id', '=', uid), ('name', '=', "Mark Johnson")])
|
||||
if emp_id:
|
||||
employee = obj_attendance.read(cr, uid, emp_id)[0]
|
||||
self.write(cr, uid, [ref('hr_sign_in_out_ask_markjohnson0')], {'emp_id': emp_id[0]})
|
||||
#self.sign_in(cr, uid, [ref("hr_sign_in_out_ask_markjohnson0")], {"active_ids": [ref("hr_attendance.menu_hr_attendance_sigh_in_out")]})
|
||||
|
||||
-
|
||||
Finally i will check the state of the employee is present.
|
||||
-
|
||||
!record {model: hr.sign.in.out, id: hr_sign_in_out_markjohnson0}:
|
||||
name: Mark Johnson
|
||||
state: present
|
||||
|
Loading…
Reference in New Issue