Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
2 Відповіді
3332 Переглядів

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.

Related Posts Відповіді Переглядів Дія
0
бер. 25
492
4
квіт. 24
172893
0
груд. 23
1489
5
лют. 25
224467
1
груд. 22
2413