mirror of
https://github.com/odoo/documentation.git
synced 2025-12-12 07:29:27 +07:00
[IMP] studio: clarifying logic for time-triggered automation rules
task-5335209 closes odoo/documentation#15397 Signed-off-by: Siobhan McGonigle (mcsi) <mcsi@odoo.com>
This commit is contained in:
@@ -18,14 +18,10 @@ To create an automation rule with **Odoo Studio**:
|
|||||||
#. Give the automation rule a clear, meaningful name that identifies its purpose.
|
#. Give the automation rule a clear, meaningful name that identifies its purpose.
|
||||||
#. Select the :ref:`Trigger <studio/automated-actions/trigger>` and, if necessary, fill in the
|
#. Select the :ref:`Trigger <studio/automated-actions/trigger>` and, if necessary, fill in the
|
||||||
fields that appear on the screen based on the chosen trigger.
|
fields that appear on the screen based on the chosen trigger.
|
||||||
#. Click :guilabel:`Add an action` in the :guilabel:`Actions To Do` tab.
|
#. Click :ref:`Add an action <studio/automated-actions/action>` in the :guilabel:`Actions To Do`
|
||||||
|
tab.
|
||||||
.. tip::
|
#. Select the :guilabel:`Type` of action and complete the relevant fields based on the chosen
|
||||||
If no explicit name is entered, the name of the action will be automatically generated based
|
action.
|
||||||
on the action you define; the name can be updated at any time.
|
|
||||||
|
|
||||||
#. Select the :guilabel:`Type` of :ref:`action <studio/automated-actions/action>` and complete the
|
|
||||||
relevant fields based on the chosen action.
|
|
||||||
#. Click :guilabel:`Save & Close` or, to define additional actions, :guilabel:`Save & New`.
|
#. Click :guilabel:`Save & Close` or, to define additional actions, :guilabel:`Save & New`.
|
||||||
|
|
||||||
.. example::
|
.. example::
|
||||||
@@ -142,44 +138,88 @@ Timing Conditions
|
|||||||
Trigger automated actions at a point in time relative to a date field or to the creation or update
|
Trigger automated actions at a point in time relative to a date field or to the creation or update
|
||||||
of a record. The following triggers are available:
|
of a record. The following triggers are available:
|
||||||
|
|
||||||
- :guilabel:`Based on date field`: The action is triggered a defined period of time before or after
|
- :guilabel:`Based on date field`: The action is triggered a defined period of time *before or
|
||||||
the date of the selected date field.
|
after* the date of the selected date field, e.g., 30 days before the contract end date.
|
||||||
- :guilabel:`After creation`: The action is triggered a defined period of time after a record is
|
- :guilabel:`After creation`: The action is triggered a defined period of time after a record is
|
||||||
created and saved.
|
created and saved.
|
||||||
- :guilabel:`After last update`: The action is triggered a defined period of time after an existing
|
- :guilabel:`After last update`: The action is triggered a defined period of time after an existing
|
||||||
record is edited and saved.
|
record is edited and saved.
|
||||||
|
|
||||||
You can then define:
|
To configure a :guilabel:`Timing Conditions` trigger, with :ref:`developer mode activated
|
||||||
|
<developer-mode>`:
|
||||||
|
|
||||||
- a :guilabel:`Delay`: Specify the number of :guilabel:`Minutes`, :guilabel:`Hours`,
|
#. Select the appropriate :guilabel:`Trigger` from the :guilabel:`Timing Conditions` category.
|
||||||
:guilabel:`Days`, or :guilabel:`Months` after which the action should be triggered. If you
|
If you select the :guilabel:`Based on date field` trigger, select the relevant date field.
|
||||||
selected the :guilabel:`Based on date field` trigger, the action can be triggered
|
#. Configure the :guilabel:`Delay` to determine the *execution date time* of the action(s). To
|
||||||
:guilabel:`After` or :guilabel:`Before` the selected date field.
|
do so, enter the number of :guilabel:`Minutes`, :guilabel:`Hours`, :guilabel:`Days`, or
|
||||||
|
:guilabel:`Months` after which the action should be triggered. If you selected the
|
||||||
|
:guilabel:`Based on date field` trigger, the action can be triggered :guilabel:`After` or
|
||||||
|
:guilabel:`Before` the selected date field.
|
||||||
|
#. Optionally, :ref:`add conditions <studio/automated-actions/conditions>` that the record must meet
|
||||||
|
before and/or after the rule is triggered.
|
||||||
|
#. Click :icon:`fa-cloud-upload` :guilabel:`Save manually`.
|
||||||
|
#. Click :icon:`fa-arrow-right` :guilabel:`Scheduled action` to open the :guilabel:`Automation
|
||||||
|
Rules: check and execute` scheduled action.
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
By default, the scheduler checks for time-triggered automation rules every 240 minutes, or 4
|
This scheduled action checks for execution date times that have been reached since its
|
||||||
hours. This frequency is generally sufficient for delays such as 3 months after the order date
|
previous run, and executes the related action(s), if relevant. By default, the scheduled
|
||||||
or 7 days after the last update.
|
action is set to :guilabel:`Execute Every` 4 hours, which is generally sufficient for delays
|
||||||
|
such as 3 months after the order date or 7 days after the last update.
|
||||||
|
|
||||||
For delays of less than the equivalent of 2400 minutes, or 40 hours, the system recalculates
|
If any automation rule has a time-based trigger with a delay of less than the equivalent of 40
|
||||||
the frequency of this check to ensure that more granular delays, e.g., 1 hour before the event
|
hours, e.g., 3 hours before the event start date time, the frequency of the scheduled action
|
||||||
start date and time, or 30 minutes after creation, can be respected as closely as possible.
|
is automatically increased, e.g., to :guilabel:`Execute Every` 18 minutes. This allows the
|
||||||
|
action to be executed closer to its scheduled execution date time.
|
||||||
|
|
||||||
To view or manually edit the frequency of the scheduler for a time-triggered automation rule,
|
#. Click :guilabel:`Run manually` at the top left.
|
||||||
with :ref:`developer mode activated <developer-mode>`, click :guilabel:`Scheduled action`.
|
|
||||||
|
|
||||||
.. image:: automated_actions/trigger-delay-scheduled-action.png
|
.. warning::
|
||||||
:alt: Direct link to scheduled action for automations
|
This step is critical to prevent the rule from running retroactively on historical records.
|
||||||
|
Running the scheduled action manually initializes the timestamp of its *last run* in the
|
||||||
|
automation rule, which is a key element of the rule's :ref:`execution logic
|
||||||
|
<studio/automated-actions/trigger-timing-conditions-logic>`.
|
||||||
|
|
||||||
In the :guilabel:`Automation Rules: check and execute` scheduled action that opens, update the
|
#. Click the automation rule name in the breadcrumbs to return to the automation rule setup.
|
||||||
value of the :guilabel:`Execute Every` field, if desired. Clicking :guilabel:`Run Manually`
|
#. Add the :ref:`action(s) to be executed <studio/automated-actions/action>` then, when all actions
|
||||||
triggers the scheduled action to run immediately. To return to the automation rule setup, click
|
have been defined, click :icon:`fa-cloud-upload` :guilabel:`Save manually`.
|
||||||
the automation rule name in the breadcrumbs.
|
|
||||||
|
|
||||||
- :guilabel:`Extra Conditions`: Click :guilabel:`Add condition`, then specify the conditions to be
|
The action is executed the first time the :guilabel:`Automation Rules: check and execute` scheduled
|
||||||
met for the automation rule to run. Click :guilabel:`New Rule` to add another condition.
|
action runs after the execution date time is reached, and when the conditions are met.
|
||||||
|
|
||||||
The action is executed when the delay is reached and the conditions are met.
|
.. _studio/automated-actions/trigger-timing-conditions-logic:
|
||||||
|
|
||||||
|
Execution logic
|
||||||
|
~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
When using a time-based trigger, an action is only executed when the execution date time falls
|
||||||
|
*between* the last run of the scheduled action and the current run (whether scheduled or run
|
||||||
|
manually), i.e.:
|
||||||
|
|
||||||
|
**last run --> execution date and time --> current run**
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
Running the :guilabel:`Automation Rules: check and execute` scheduled action manually does not
|
||||||
|
necessarily result in a rule's action being executed. When testing an automation rule with a
|
||||||
|
time-based trigger, ensure that this sequence is true, then check if the action has been
|
||||||
|
executed.
|
||||||
|
|
||||||
|
.. example::
|
||||||
|
On the morning of October 15, you create an automation rule that triggers the sending of an email
|
||||||
|
30 days before the :guilabel:`Contract end date`; contracts end at 11:59 pm on their contract end
|
||||||
|
date. During the creating of the rule, the :guilabel:`Automation Rules: check and execute`
|
||||||
|
scheduled action was run manually at 11:00 am and is set to run every four hours thereafter.
|
||||||
|
|
||||||
|
This new automation rule will apply for contracts whose end date is at least 30 days *after* the
|
||||||
|
creation of the rule, i.e., an end date of November 14 or later.
|
||||||
|
|
||||||
|
For a contract with an end date of November 14, the execution date time of the action is 11:59 pm
|
||||||
|
on October 15. The action will therefore be executed the first time the :guilabel:`Automation
|
||||||
|
Rules: check and execute` scheduled action runs after that date and time has passed, i.e.,:
|
||||||
|
|
||||||
|
- last run of the scheduled action: 11:00 pm on October 15
|
||||||
|
- execution date time: 11:59 pm on October 15
|
||||||
|
- current run of the scheduled action: 3:00 am on October 16
|
||||||
|
|
||||||
.. _studio/automated-actions/trigger-custom:
|
.. _studio/automated-actions/trigger-custom:
|
||||||
|
|
||||||
@@ -247,8 +287,10 @@ click :guilabel:`Add an action` in the :guilabel:`Actions To Do` tab to define t
|
|||||||
executed.
|
executed.
|
||||||
|
|
||||||
.. tip::
|
.. tip::
|
||||||
You can define multiple actions for the same automation rule. By default, actions are executed in
|
- If no explicit name is entered, the name of the action will be automatically generated based
|
||||||
the order in which they were defined.
|
on the action you define; the name can be updated at any time.
|
||||||
|
- You can define multiple actions for the same automation rule. By default, actions are executed
|
||||||
|
in the order in which they were defined.
|
||||||
|
|
||||||
This means, for example, that if you define an :guilabel:`Update record` action and then a
|
This means, for example, that if you define an :guilabel:`Update record` action and then a
|
||||||
:guilabel:`Send email` action where the email references the field that was updated, the email
|
:guilabel:`Send email` action where the email references the field that was updated, the email
|
||||||
|
|||||||
Reference in New Issue
Block a user