How-to: A detailled look into recurring tasks in Odoo v16

The technics behind the powerful Odoo-function

In the dynamic realm of business management, staying organized is the key to success. For enterprises relying on Odoo v16, the introduction of recurring tasks in 2020 is a game-changer. Recurring tasks empower users to automate routine activities, ensuring that important actions are never overlooked. This feature is seamlessly integrated into the Odoo v16 platform, offering a flexible and user-friendly approach to managing ongoing responsibilities.

​However, the currently available documentation (see https://www.odoo.com/documentation/16.0/applications/services/project/tasks/recurring_tasks.html)
only gives a broad overview to this feature and leaves out the details - like when and how exactly tasks are being created. In this blog-article, we will dive into those details for you to being able to fully understand the feature. Note that this is not an introduction to task-recurrence. For how to enable them, please see the standard Odoo documentation. 

Behind the scenes of recurrent tasks

When activating the recurrence at task level (open task and click on Recurrent => Recurrent), Odoo lets you select the recurrence interval. By saving this information, Odoo will not only save this information to the project.task-model but also to a newly created record of type "https://project.task.recurrence"./ From now on, this model will be the one holding all the information about your recurrence and also group all tasks together that have been created out of this recurrency. The end user will most likely never have to deal with the https://project.task.recurrence/ model directly as changes can be made in any recurrent task and will automatically be propagated to the recurrence.

How and when are recurrent tasks actually created?

Odoo utilizes a scheduled action to create recurring tasks. To open the scheduled action, enable developer mode in Odoo and navigate to Settings => Technical => Scheduled Actions => "Project: Create Recurring Tasks":

Here you can enable or disable the scheduled action and also change the intervall and time that the scheduled action runs at. In our example, the scheduled action runs every day at around 4am. The scheduled action calls the function "_cron_create_recurring_tasks" of the model "task.recurrence".

What exactly happens when _cron_create_recurring_tasks is triggered?

As mentioned earlier, the scheduled action runs on the model "task.recurrence". When running, the action does the following:

  • It retrieves all task-recurrencies with a "next_recurrent_date" that is smaller or equal to the current date.
  • For all recurrencies found, a method called _create_next_task is called. This method actually creates the next task by retrieving the latest task of a task.recurrence and copies all the fields that are defined within the method "_get_recurring_fields()". At the time of writing, these fields are defined as follows:

  • Also, it copies all subtasks of the recurrent task. If subtasks have their own recurrency set, the recurrency will be copied, thus creating their "own life" and decoupling it of the initial subtask.
  • In addition, the task-stage is set to the first available stage within the project. If there is none available, it is set to the stage of the last task it was copied from.
  • After finishing the creation of the next task, the "next_recurrent_date" is set if:
    • there are still recurrences left
    • the current date is still smaller then the "until"-Date set in the task-recurrence-definition or it is set to "forever"

Key takeaways of this process::

  • Recurrent tasks are not created upfront but only by the time the "next_recurrent_date" of a task.recurrence is smaller or equal to the current date.
  • All information is taken from the "last" available task (maximum database-id) within a recurrency.
  • It does not depend on any task stage (done or not) whether a new task will be created or not.
  • Even if the scheduled action will run multiple times per day, it will not affect the amount of tasks created as the "next_recurrence_date" will be set after the first creation of a task. 

Findings we had when researching this topic:

  • When editing an existing task that has recurrence activated, it asks the user whether he would like to edit "this task", "This and following tasks" or "all tasks".
    This setting simply tells Odoo about how to handle tasks currently existant in the system. For newly created tasks, it will always take the information available in the task with the highest database-id (usually the last one created) and copy it.
  • Odoo will show an information-snippet within the task, showing the next creation-dates of the recurrency. This snippet is only valid at the time of creation of this task as it will always take the current date as the start-date for this simulation (see function _get_recurrence_start_date() within function _compute_recurrence_message()). If you open up an existing task (i.e. set with recurrency to repeat every 3 months), this information might not be correct.

  • To see exactly, when the next creation will be triggered, one must open the corresponding task.recurrence-model. Unfortunately it is not possible to do this directly from the user interface in Odoo standard. A workaround would be to set the recurrence-id-field to be visible within the task-form-view. You can do that by
    • enabling developer mode
    • navigate to the task you want to look up
    • click on the bug-icon and select "Edit view: form"
    • look for an xml-tag with the name set to "recurrence_id" and set invisible="1" to invisible="0"

    • Save and refresh the page. A link to the task.recurrency should now be visible at the top of the form view:
    • Beachten Sie, dass diese Änderung für alle Benutzer sichtbar ist, daher sollten Sie Ihre Änderung so schnell wie möglich rückgängig machen. Beachten Sie ebenfalls, dass diese Änderung nur vorübergehend ist, da wir die Ansicht nicht korrekt überschrieben haben, um update-resistent zu sein. Wenn Sie das Projektmodul aktualisieren, wird diese Änderung überschrieben.
  • When opening the recurrence, you can see the all assigned tasks and also the "next recurrence date" which lets you know when the scheduled action will create a new task again:

Conclusio

Recurring tasks in Odoo redefine the way businesses manage their workflows. By automating routine activities, streamlining scheduling processes, and providing insightful reporting, Odoo v16 empowers organizations to achieve unparalleled efficiency. Embrace the power of recurring tasks and elevate your business management to new heights with Odoo v16.


​For more details on how to leverage recurring tasks and other features in Odoo v16, consult the official documentation or get in touch with our expert team.


Get in touch


Please note that Odoo is a rapidly changing system with lots of improvements every day. This blog article discusses the functionality of the task-recurrency functionality as per November 2023.


Equipment maintenance in Odoo
Manage and maintain your inventory in Odoo.