[FIX] hr_attendance: fix mismatch between user and employee in test
authorRaphael Collet <rco@openerp.com>
Thu, 22 Dec 2011 15:39:11 +0000 (16:39 +0100)
committerRaphael Collet <rco@openerp.com>
Thu, 22 Dec 2011 15:39:11 +0000 (16:39 +0100)
bzr revid: rco@openerp.com-20111222153911-olkpskmw23mbmyed

addons/hr_attendance/test/attendance_process.yml

index 78bc769..bd10541 100644 (file)
@@ -1,19 +1,15 @@
 -
   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: Antony Lesuisse
-    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', '=', "Antony Lesuisse")])
+    hr_employee = self.pool.get('hr.employee')
+    uid = ref('base.user_al')
+    emp_ids = hr_employee.search(cr, uid, [('user_id', '=', uid)])
     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")])
+        employee = hr_employee.browse(cr, uid, emp_ids)[0]
+        id = self.create(cr, uid, {'emp_id': employee.id, 'name': employee.name, 'state': employee.state})
+        self.si_check(cr, uid, [id])
 -
   I check that Employee is "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', '=', "Antony Lesuisse")])
+    hr_employee = self.pool.get('hr.employee')
+    uid = ref('base.user_al')
+    emp_ids = hr_employee.search(cr, uid, [('user_id', '=', uid)])
     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")])
+        employee = hr_employee.browse(cr, uid, emp_ids)[0]
+        id = self.create(cr, uid, {'emp_id': employee.id, 'name': employee.name, 'state': employee.state})
+        self.si_check(cr, uid, [id])
 -
   I select Last Sign Out date.
 -
-  !record {model: hr.sign.in.out.ask, id: hr_sign_in_out_ask_Antoine_Philippe}:
+  !record {model: hr.sign.in.out.ask, id: hr_sign_in_out_ask_Antony}:
     last_time: !eval time.strftime('%Y-%m-%d %H:%M:%S')
-    name: Antoine Philippe
+    name: Antony
 -
   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', '=', "Antony Lesuisse")])
+    import time
+    hr_employee = self.pool.get('hr.employee')
+    uid = ref('base.user_al')
+    emp_ids = hr_employee.search(cr, uid, [('user_id', '=', uid)])
     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]})
+        employee = hr_employee.browse(cr, uid, emp_ids)[0]
+        id = self.create(cr, uid, {'emp_id': employee.id, 'name': employee.name, 'last_time': time.strftime('%Y-%m-%d %H:%M:%S')})
 -
   Finally i check the employee is present.
 -