Search code examples
pythonodooodoo-13

Odoo 13 how to run a action via api?


url = "ip"
db = "dbname"
username = "user"
password = "admin"

common = xmlrpc.client.ServerProxy('{}/xmlrpc/2/common'.format(url))
uid = common.authenticate(db, username, password, {})

actions = models.execute_kw(db, uid, password, 'ir.cron', 'search', [[['name', '=', 'Mail: Email Queue Manager']]])
print(actions)

Returns [2]

But I am not sure how to run this action? I have tried looking at the documentation, but I don't see an example on how to run an action?


Solution

  • You can run the action manually by calling the method_direct_trigger method.

    Example:

    models.execute_kw(db, uid, password, 'ir.cron', 'method_direct_trigger', [actions])