我已经创建了计划任务,并且在本地主机中,具有该功能的调度程序正常工作。在服务器中,我设置呼叫数= 10,间隔单位=分钟和间隔号= 1
问题是服务器在特定升级后启动,仅一分钟后,呼叫数显示为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 Scheduler调用
<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>
答案 0 :(得分:1)
您遇到的问题是Repeat missed
当您将其设置为True时,这意味着当服务器重新启动时应该执行服务器关闭时丢失的错过的操作,因此如果服务器停机至少10分钟,则重新启动它时所有操作在此期间错过的将尽快执行。所以不要解开该选项,它在您的代码中实际为False
(只需升级您的模块以覆盖用户界面中的选项)
您还可以设置从xml
触发函数的Argument <field eval="'(True,)'" name="args"/>