我希望有一个计划动作,该动作每天从凌晨1点到凌晨6点之间依次执行。
我该如何实现?
由于我仅有的菜单是“ Execute Every”和“ Next Execution Date”,所以我不知道如何提及特定的小时数范围。我正在使用Odoo 11。
答案 0 :(得分:0)
您可以使用计划更频繁运行的包装器操作。
def action_function():
# you will need to store a value (is_running: True|False) in the database, maybe in ir.config_parameter
if current_hour not in (1, 2, 3, 4, 5):
return None
elif is_running:
return None
else:
# Mark that the action is in process, have to commit to the database
is_running = True
self.env.cr.commit()
# Then call your actual action function
do_some_real_thing()
# Mark that the action is done
is_running = False
基本上,以下步骤的包装动作会像每10分钟一样频繁地重复一次。