Openerp Scheduler 正在运行,但附加功能未执行

Openerp Scheduler is working but the attached funciton not executing

我尝试使用 Openerp 调度程序执行一个函数,但它没有任何改变。如果我 运行 该函数仅能正常工作,但不能与调度程序一起工作。请帮我解决这个问题。

在 hr_holidays.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">-1</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 看起来像这样;

函数

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

您只需要为该参数设置默认值,无需通过 cron 传递它,如果函数中需要它,则从 cron 传递它。

def allocate_on_probations(self, cr, uid, ids,tl=False, 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

如果它是强制性的,那么您需要从 args

中的 cron 传递 t1 值