Configure Scheduled Actions in Odoo 17

HISHAM
April 15, 2024
scheduled-actions-in-odoo

With Odoo Scheduled Actions feature, users can set up regular tasks to be executed automatically on a predetermined schedule, eliminating the need for manual intervention. This function is essential for streamlining repetitive tasks, making the best use of available resources, and preserving uniformity within the ERP system. Scheduled Actions offer a strong foundation for time-driven automation, regardless of the task—such as scheduling complex workflows, updating records, or sending automated reminders.

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

Write the Scheduled action record in the “ir_cron_data.xml” file located in your module’s data
directory to create a scheduled action.

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

  • noupdate=”1″: The data for the already existing records cannot be updated. This attribute is usually used to achieve this.
  • id and model of record tag: The ‘id’ of a record will be unique and it will be saved on the given model. In this case, it will be in it. cron model.
  • name: This is typically used for display purposes. It specifies the name of the cron job
  • model_id: It links to a specific model the user requires. In this case, the cron job is associated with the “sale. order” model.
  • state: It indicated that the cron job is implemented using Python code. The state is set to “code” meaning it will execute Python code.
  • code:    It contains Python code associated with the cron job.    Here it calls the “action_cron_test_method()” method on the “model” object.
  • user_id: It specifies the user associated with the cron job. For most cases, it’s set to root user.
  • interval_number: It specifies when the cron job runs, in this case cron job should run every 1 unit of the specified interval type.
  • interval_type: It specifies interval type. Here it says ‘days’ so the cron job should run every day.
  • number call: This parameter sets the maximum number of times the automated action should run. – 1, indicating that the cron job should run indefinitely.

After adding code don’t forget to add it in your manifest and also add the function action_cron_test_method() in the sale order model.

After adding your scheduled action, upgrade your module and you will be able to see this in your Scheduled actions from the technical menu in settings.

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

In Odoo scheduled actions are mainly used to do recurring tasks, which ensures consistency and efficiency in ERP environment. Scheduled actions can be also used for sending reminders, updating records or triggering complex workflows.

"Unlock the Full Potential of Your Business with Odoo ERP!"

"Get a Cost Estimate for Your ERP Project, Absolutely FREE!"

Get a Free Quote

Leave a Reply

Your email address will not be published. Required fields are marked *