跳至内容
菜单
此问题已终结
2 回复
3752 查看

Odoo 14 EE

I have a Scheduled Action.  In the Python Code, I would like to call the action itself (the record of ir.cron) to get ir_cron.lastcall so can pass the value of the last time it ran to the method (e.g. method.my_custom_method(lastcall)).

How can I do this?

形象
丢弃
最佳答案
cron_name = 'your_action_name'
cron_id = models.execute_kw(db, uid, password, 'ir.cron', 'search', [
[['cron_name', '=', cron_name]]
])

That should give you the id of your action.


形象
丢弃
最佳答案

I've tried logging the nextcall field on the ir.cron

next = env['ir.cron'].browse(37).read(['nextcall'])
log(str(next)), level='info')

while setting the initial date to somewhere in the past and let it repeat missed intervals. I did get 24 log results but in all the logs the "nextcall" values were the same

[{'id': 37, 'nextcall': datetime.datetime(2022, 7, 25, 23, 0)}]

Next I'll look for a context
形象
丢弃

Yes, because you hardcoded the id, so you will only get results of that same action.

相关帖文 回复 查看 活动
0
3月 25
1514
4
4月 24
174376
0
12月 23
2279
5
7月 25
228500
1
12月 22
3412