DEV Community

Cover image for Scheduled actions in Odoo
Jeevachaithanyan Sivanandan
Jeevachaithanyan Sivanandan

Posted on • Updated on

Scheduled actions in Odoo

To create a scheduled action in Odoo, navigate to Settings > Scheduled Actions. Here, you'll find a list of existing actions. Click on any action to view its details.

As depicted in the screenshot, each action corresponds to a specific model and method within that model. You can customize the execution time, frequency, and other settings for each action.

Image description

To create your own action, follow these steps:

  1. In your custom module, create a new file named cron.xml within the data folder.

  2. Add the following XML code to the cron.xml file:

    <record id="custom_cron_job" model="ir.cron">
    <field name="name">Custom Cron Job</field>
    <field name="model_id" ref="custom_module.model_remote_warehouse"/>
    <field name="interval_number">1</field>
    <field name="interval_type">days</field>
    <field name="numbercall">-1</field>
    <field name="active" eval="True"/>
    <field name="code">model_remote_warehouse.update_remote_products_report()</field>
    </record>

In this XML code:

  • <field name="model_id" ref="custom_module.model_remote_warehouse"/> specifies the full model name and method to be executed, such as 'custom_module'.name_of_the_method. In our example, the method update_remote_products_report() is defined in the remote_products.py model file.

This setup ensures that the specified method will be executed each time the scheduled action runs, allowing you to perform custom tasks as needed.

important

dont forget to add the name of the action method as in the screenshot

Image description

Top comments (0)