Enable Dark Mode!
how-to-configure-scheduled-actions-in-odoo-17.jpg
By: Vishnuraj P

How to Configure Scheduled Actions in Odoo 17

Technical Odoo 17

Scheduled Actions in Odoo empower users to automate specific operations on a scheduled basis, ensuring that recurring tasks are executed without manual intervention. This feature is instrumental in automating routine processes, optimizing resource utilization, and maintaining consistency in the ERP environment. Whether it's sending automated reminders, updating records, or triggering complex workflows, Scheduled Actions provide a robust framework for time-driven automation.

We can see all the scheduled actions from “Scheduled Actions” under  “Technical” from the settings.

How to Configure Scheduled Actions in Odoo 17-cybrosys

Create a new scheduled action

For creating a scheduled action, write the Scheduled action record in the “ir_cron_data.xml” file in the data directory of your module.

Here is the sample code for it.

    <data noupdate="1">
        <record id="ir_cron_action_to_do" model="ir.cron">
            <field name="name">Test Action To Do</field>
            <field name="model_id" ref="base.model_res_partner"/>
            <field name="state">code</field>
            <field name="code">model.action_cron_test_method()
            </field>
            <field name="user_id" ref="base.user_root"/>
            <field name="interval_number">1</field>
            <field name="interval_type">days</field>
            <field name="numbercall">-1</field>
        </record>

The breakdown of each line from the provided code from here is

- noupdate="1": attribute of the data tag indicates that existing records with the same ID should not be updated, the automated actions are always specified in the no update field.

- id and model of record tag: The unique ID of a record that will be saved on the given model. In this case, it will be kept in the ir.cron model. 

- name: Specifies the name of the cron job as "Test Action To Do." This name is typically used for display purposes.

- model_id: Associates the cron job with a specific model by referencing the model's ID. In this case, it's linked to the "res.partner" model.

- state: Indicates that the cron job is implemented using Python code. The state is set to "code," meaning the cron job will execute a Python method.

- code: Contains the Python code associated with the cron job. Here, it calls the "action_cron_test_method()" method on the "model" object.

- user_id: Specifies the user ID associated with the cron job. In most cases, it's set to the root user.

- interval_number: It indicates that the cron job should run every 1 unit of the specified interval type.

- interval_type: Specifies the interval type. Here, it is set as "days." That means the cron job is configured to run every day.

- numbercall: This parameter sets the maximum number of times the automated action should run. -1, indicating that the cron job should run indefinitely.

After adding this XML code in ir_cron_data.xml file, don't forget to include this file in your manifest and add the “action_cron_test_method” method in the res.partner model for executing the code.

When you successfully add the scheduled action and upgrade your module, you can see this in your Scheduled actions from the Technical menu in Settings.

How to Configure Scheduled Actions in Odoo 17-cybrosys

We can also create/ configure the scheduled actions from the UI from here.

In Odoo, Scheduled Actions automate recurring tasks, ensuring consistency and efficiency in the ERP environment, whether it's sending reminders, updating records, or triggering complex workflows. If you want to learn how to set up scheduled actions in Odoo 16, you can find more information by reading the relevant documentation. 


If you need any assistance in odoo, we are online, please chat with us.



0
Comments



Leave a comment

 


whatsapp
location

Calicut

Cybrosys Technologies Pvt. Ltd.
Neospace, Kinfra Techno Park
Kakkancherry, Calicut
Kerala, India - 673635

location

Kochi

Cybrosys Technologies Pvt. Ltd.
1st Floor, Thapasya Building,
Infopark, Kakkanad,
Kochi, India - 682030.

location

Bangalore

Cybrosys Techno Solutions
The Estate, 8th Floor,
Dickenson Road,
Bangalore, India - 560042

Send Us A Message