Ejemplo n.º 1
0
 def clock_emps_get_all(self, cr, uid, clock_id, ret_dict = False, pwd = False, finger_print = False, context=None):
     if not clock_id:
         return []
             
     clock = clock_util.clock_obj()
     clock_data = self.pool.get('hr.clock').read(cr, uid, clock_id, ['ip','port'], context=context)
     clock_util.clock_connect(clock, clock_data['ip'], clock_data['port'])
     
     #get all employees on clock
     clock_emps = clock_util.clock_user_get_all(clock, ret_dict = ret_dict, pwd=pwd, finger_print=finger_print)
     
     clock_util.clock_disconnect(clock)
     
     return clock_emps
Ejemplo n.º 2
0
 def clock_emps_delete(self, cr, uid, order_data, context=None):
     if not order_data:
         return False
     #update data to clock
     clock = clock_util.clock_obj()
     clock_util.clock_connect(clock, order_data.clock_id.ip, order_data.clock_id.port)
     for emp_sync in order_data.emp_ids_sync:
         #delete all clock user data, including base info, finger print, password
         clock_util.clock_user_delete(clock, emp_sync.emp_code)
     #disconnect clock
     clock.RefreshData(1)
     clock_util.clock_disconnect(clock)
             
     return True
Ejemplo n.º 3
0
 def clock_emps_get(self, cr, uid, clock_id, emp_codes, ret_dict = False, pwd = False, finger_print = False, context=None):
     if not clock_id:
         return []
             
     clock = clock_util.clock_obj()
     clock_data = self.pool.get('hr.clock').read(cr, uid, clock_id, ['ip','port'], context=context)
     clock_util.clock_connect(clock, clock_data['ip'], clock_data['port'])
     
     #get all employees on clock
     emps_clock = []
     if ret_dict:
         emps_clock = {}
     for emp_code in emp_codes:
         emp_clock = clock_util.clock_user_get(clock, emp_code, pwd=pwd, finger_print=finger_print)
         if emp_clock:
             if ret_dict:
                 emps_clock[emp_code] = emp_clock                    
             else:
                 emps_clock.append(emp_clock)
             
     clock_util.clock_disconnect(clock)
     
     return emps_clock
Ejemplo n.º 4
0
 def clock_emps_set(self, cr, uid, order_data, context=None):
     if not order_data:
         return False
     #store the password and finger print to update
     emps_fp_pwd = {}
     if order_data.sync_opt_pwd or order_data.sync_opt_fp:
         emp_codes = [emp.emp_code for emp in  order_data.emp_ids_sync]
         emp_obj = self.pool.get('hr.employee')
         emp_ids = emp_obj.search(cr, uid, [('emp_code','in',emp_codes)],context=context)
         read_flds = ['emp_code']
         if order_data.sync_opt_pwd:
             read_flds += ['clock_pwd']
         if order_data.sync_opt_fp:
             read_flds += ['clock_fp1','clock_fp2','clock_fp3','clock_fp4','clock_fp5','clock_fp6','clock_fp7','clock_fp8','clock_fp9','clock_fp10',]
         emps = emp_obj.read(cr, uid, emp_ids, read_flds, context=context)
         for emp in emps:
             emps_fp_pwd[emp['emp_code']] = emp
     #update data to clock
     clock = clock_util.clock_obj()
     clock_util.clock_connect(clock, order_data.clock_id.ip, order_data.clock_id.port)
     for emp_sync in order_data.emp_ids_sync:
         new_clock_pwd = False
         new_clock_fps = []
         if order_data.sync_opt_pwd or order_data.sync_opt_fp:
             fp_pwd = emps_fp_pwd[emp_sync.emp_code]
             if order_data.sync_opt_pwd:
                 new_clock_pwd += fp_pwd['clock_pwd']
             if order_data.sync_opt_fp:
                 for i in range(1,11):
                     new_clock_fps.append(fp_pwd['clock_fp%s'%(i,)])
         #set clock user data
         clock_util.clock_user_set(clock, emp_sync, order_data.sync_opt_pwd, new_clock_pwd, order_data.sync_opt_fp, new_clock_fps)
     #disconnect clock
     clock.RefreshData(1)
     clock_util.clock_disconnect(clock)
             
     return True