2016-08-23 110 views
0

我已經創建了計劃任務,並在本地主機調度程序與該功能工作正常。在服務器我設置呼叫數= 10,間隔單位=分鐘和間隔數= 1Openerp Schdular立即執行

問題是當服務器啓動後,特定升級後,只有一分鐘後,呼叫數顯示爲0而不是9

請幫我這個

的功能

def allocate_on_probations(self, cr, uid, ids,tl, context=None): 

     allo=0 
     state='active' 
     result = {} 


     emps=self.pool.get('hr.employee').search(cr, uid, [('current_status','=','active')], context=context) 
     if emps: 

      for r in emps: 
       hol_state=2 
       gt_dt=cr.execute("""SELECT appointed_date FROM hr_employee WHERE id= %d order by id"""%(r)) 
       gt_dd=cr.fetchone()[0] 

       #getting today details 
       today = datetime.datetime.now() 
       tt=today.date() 
       td=tt.day 
       tm=tt.month 
       ty=tt.year 

       #getting appointment date details 
       app=datetime.datetime.strptime(gt_dd, "%Y-%m-%d").date() 
       #print app 
       ay=app.year 
       am=app.month 
       ad=app.day 

       if ay==ty: 
        #compairing today and appointed date 
        comp=(tt-app) 
        chat=int(comp.days) 
        chat_mod=chat%30 
        print chat_mod 
        print r 

        if chat_mod==29: 
         hol_obj=self.pool.get('hr.holidays') 
         print hol_obj 
         condition_1=[('employee_id','=',r),('type','=','add'),('holiday_status_id','=',hol_state)] 
         hol_emp=hol_obj.search(cr, uid,condition_1, context=context) 

         if hol_emp: 

          for n in hol_emp: 
           hol_dt=cr.execute("""SELECT number_of_days_temp FROM hr_holidays WHERE id= %d order by id"""%(n)) 
           hol_dd=cr.fetchone()[0] 
           hol_inc=(hol_dd+0.5) 

           print hol_inc 
           cr.execute("""UPDATE hr_holidays SET number_of_days_temp= %d WHERE id= %d"""%(hol_inc,n)) 
           cr.execute("""UPDATE hr_holidays SET number_of_days= %d WHERE id= %d"""%(hol_inc,n)) 




     return True 

XML調度呼叫

<record id="ir_cron_scheduler" model="ir.cron"> 
      <field name="name">Casual Leave Allocation</field> 
      <field name="interval_number">1</field> 
      <field name="interval_type">minutes</field> 
      <field name="numbercall">10</field> 
      <field eval="False" name="doall"/> 
      <field eval="'hr.holidays'" name="hr.holidays"/> 
      <field eval="'allocate_on_probations'" name="allocate_on_probations"/> 
      <field eval="'()'" name="args"/> 
     </record> 

UI enter image description here

enter image description here

+0

你是通過xml還是從ui來完成的? – danidee

+0

最初我從xml調用調度程序,然後使用ui修改參數 –

+0

然後粘貼您的代碼,對於您正在運行的調度程序和函數,調試將更容易 – danidee

回答

1

您遇到的問題是Repeat missed

當你將它設置爲True,這意味着當服務器下跌應該是被遺漏遺漏行動當服務器重新啓動時執行,因此如果服務器至少停止了10分鐘,那麼當您重新啓動時,所有在該時間段內錯過的操作都將盡快執行。所以不要取消選中該選項,它實際上False在你的代碼(只是升級模塊重寫UI中的選項)

您還可以設置從XML觸發函數的參數

<field eval="'(True,)'" name="args"/>

+0

非常感謝你danidee ...它工作 –