Odoo automated transitions are a feature that allows you to automatically change the stage of a record according to predefined rules. This means no manual updates, saving time, reducing errors, and helping to ensure workflows are completed consistently. In Odoo, this is supported with Automated Actions, Scheduled Actions, Server Actions, and custom Python code.
Why Use Automated Transitions?
There are many advantages to automating state changes:
- Less work for the user to do
- Increases workflow consistency
- Minimizes human errors
- Accelerates business processes
- Keeps records current in a timely manner
Common Use Cases
- Automatic Confirmation of Orders
You can configure a sales order to be automatically confirmed when specific conditions are met, such as payment confirmation or approval completion.
- Reallocating Tasks Across Stages
All the required activities are done, then project tasks can be automatically moved to a “Done” stage.
- Changing the invoice status
Once the payment has been successfully recorded, invoices can be moved to the paid state.
- Increasing the number of support tickets
Helpdesk tickets can be set to automatically escalate to a higher priority if they are not resolved within a set time.
Methods for Creating Automated Transitions
1. Using Automated Actions
Automated Actions allow Odoo to take certain actions automatically when certain conditions are met. They can be configured directly from the user interface, which offers an easy way to automate business processes without custom development.
For example, an automated action can automatically assign a sales representative when a new lead is created or automatically update a record’s stage when certain conditions are met.
To create an Automated Action:
- Enable Developer Mode.
- Navigate to Settings > Technical > Automation > Automated Actions.
- Create a new automated action.
- Select the target model and trigger condition.
- Define the action to perform when the condition is met.
Automated Actions are good for automating simple tasks and workflow changes based on certain events without too much customization.
2. Using Scheduled Actions (Cron Jobs)
Scheduled Actions are automated actions that execute at set intervals and are capable of updating records based on criteria you define.
Example:
class HelpdeskTicket(models.Model):
_inherit = 'helpdesk.ticket'
@api.model
def cron_auto_close_tickets(self):
tickets = self.search([
('stage_id.name', '=', 'Resolved')
])
tickets.write({
'active': False
})
This technique is applicable for periodic transitions.
3. Using Server Actions
Server Actions allow you to run Python code from the Odoo interface itself, upon the occurrence of certain events. They are useful to automate workflow transitions without creating a custom module.
For example, this Server Action automatically moves a helpdesk ticket from the Resolved state to the Done state:
done_stage = env['helpdesk.stage'].search(
[('name', '=', 'Done')],
limit=1
)
if record.stage_id.name == 'Resolved' and done_stage:
record.write({
'stage_id': done_stage.id
})
In this example, record is the current helpdesk ticket that has triggered the Server Action. The action first searches for the Done stage and then checks if the current stage of the ticket is Resolved. If the condition is met, the ticket’s stage_id field is updated, and the ticket is automatically moved to the Done stage. This demonstrates how Server Actions can be used to automate workflow transitions right from the Odoo interface, without needing a custom module.
4. Using Custom Workflow Logic
With custom workflow logic, you can define automated transitions inside model methods. It’s handy when a workflow needs custom business rules, additional validations, or more advanced functionality than can be achieved with Automated Actions or Scheduled Actions.
For example, this method automatically moves a document to the Approved state when it is approved by a manager:
class DocumentRequest(models.Model):
_name = 'document.request'
_description = 'Document Request'
name = fields.Char(required=True)
state = fields.Selection([
('draft', 'Draft'),
('submitted', 'Submitted'),
('approved', 'Approved'),
], default='draft')
def action_approve(self):
self.write({
'state': 'approved'
})
For example:
- When the user clicks the approval button, the action_approve() method is called.
- The status of the record is changed automatically from Submitted to Approved.
- The transition is performed directly in Python code, making it easy to add additional validations or business logic as needed.
Custom workflow logic is best when you need an automated transition with conditions, calculations, approvals, or integrations that cannot be easily achieved using Automated Actions or Scheduled Actions.
Best Practices
- Clearly state the conditions under which each transition occurs.
- Don’t automate so much that it becomes hard to understand the workflow.
- Test automated transitions well before releasing to production.
- To improve performance when updating many records, use batch operations.
- Record important transitions for audit and troubleshooting purposes.
Odoo Automatic Transitions enables organizations to be more productive by making sure that the automatic transition of records from one state to another is performed when certain criteria are met. Organizations will be able to reap the benefits, whether they use the Automated Action, Scheduled Action, Server Action, or run custom code using the Python programming language.
To read more about How to Configure Automated Actions in Odoo 18, refer to our blog How to Configure Automated Actions in Odoo 18.