2017-05-30 58 views
0

我試圖使用Biometric Device Integration模塊來從生物特徵識別設備導入考勤,但是我發現它在每次導入事件後都刪除了出勤記錄想。所以我刪除它刪除上座率從我的機器,但在這裏,我再次發現,當我導入函數複製人次如何將舊記錄與新記錄進行比較然後導入新記錄

我要的是它的舊記錄(人次)用新的和進口的只是新的記錄進行比較的功能。

@classmethod 
 
    def import_data_classmethod(
 
      cls, biometric_machine, biometric_data_obj, biometric_user_obj,): 
 
     attendances = biometric_machine.getattendance() 
 
     # Sorted elements using user_id and timestamp 
 
     attendances.sort(key=lambda x: (x.user_id, x.timestamp)) 
 
     for attendance in attendances: 
 
      user = biometric_user_obj.search([ 
 
       ['biometric_id', '=', int(attendance.user_id), ], ],) 
 
      if not attendance.action_perform: 
 
       continue 
 
      if not user.employee_id: 
 
       biometric_data_obj.create(
 
        {'biometric_user_id': user.id, 
 
        'datetime': attendance.timestamp, 
 
        'action_perform': attendance.action_perform, },) 
 
       continue 
 

 
       
 
      biometric_data_obj.create_hr_attendace(
 
       user.employee_id.id, attendance.timestamp, 
 
       attendance.action_perform, 
 
       user.biometric_device.id,) 
 
     #biometric_machine.clean_attendance()

回答

0

@classmethod 
 
    def import_data_classmethod(
 
      cls, biometric_machine, biometric_data_obj, biometric_user_obj,): 
 
     attendances = biometric_machine.getattendance() 
 
     # Sorted elements using user_id and timestamp 
 
     attendances.sort(key=lambda x: (x.user_id, x.timestamp)) 
 
     for attendance in attendances: 
 
      user = biometric_user_obj.search([ 
 
       ['biometric_id', '=', int(attendance.user_id), ], ],) 
 

 

 
      del_atten_ids = biometric_data_obj.search([('biometric_user_id','=',user.id),('datetime','=',str(attendance.timestamp))]) 
 
      if del_atten_ids: 
 
          # hr_attendance.unlink(cr,uid,del_atten_ids) 
 
       print "nothing to do" 
 
      elif not del_atten_ids: 
 

 

 

 

 

 
       if not attendance.action_perform: 
 
        continue 
 
       if not user.employee_id: 
 
        biometric_data_obj.create(
 
        {'biometric_user_id': user.id, 
 
        'datetime': attendance.timestamp, 
 
        'action_perform': attendance.action_perform, },) 
 
        continue 
 

 

 
       biometric_data_obj.create_hr_attendace(
 
       user.employee_id.id, attendance.timestamp, 
 
       attendance.action_perform, 
 
       user.biometric_device.id,) 
 
     #biometric_machine.clean_attendance()

相關問題