Workflows and automation
Introduction to automation in Odoo
Automating processes in Odoo raises operational efficiency: it reduces manual tasks, keeps processes consistent and frees time for work of higher value.
The types of automation available
Odoo offers several complementary automation mechanisms:
- automated actions: triggering actions when conditions are met;
- scheduled actions: running actions on a calendar;
- workflows: sequencing the steps of a process;
- alert rules: notifications based on conditions;
- email and SMS templates: automated communication;
- marketing automation (Enterprise edition).
Note
These tools can be combined to build complex automations suited to your own business processes.
Automated actions
The principle
Automated actions run an action when a particular event occurs and certain conditions are met:
- Open Settings › Technical › Automation › Automation Rules.
- Create a new rule.
- Set the basic parameters: - a descriptive name; - the model concerned: contacts, invoices, orders and so on; - the type of trigger: creation, update, periodic and so on.
- Configure the conditions under which it applies, through filters.
- Define the action to run.
- Enable the automation.
The triggers available are:
- On creation: the action runs when a new record is created.
- On update: the action runs when a record is changed.
- On creation and update: combines the two previous triggers.
- On archive and unarchive: the action runs when a record changes state.
- Time-based: the action runs after a delay or on a given date.
- Based on a Python expression: for advanced custom triggers.
The types of action available
Automated actions can carry out various operations:
- sending an email or an SMS;
- creating, updating or deleting records;
- running a Python method;
- adding followers to a document;
- creating an activity, that is a task to carry out;
- sending an internal notification to users.
Tip
For complex automations, you can chain several automated actions that fire in cascade.
Examples of use
Automated actions serve many scenarios:
- sending a welcome email to every new customer;
- creating an approval task when an order exceeds a given amount;
- categorising products automatically against certain criteria;
- updating the sales prices when the purchase cost changes;
- notifying the sales manager of high-value opportunities;
- creating a down payment invoice automatically when an order is confirmed.
Scheduled actions
Configuring periodic actions
Scheduled actions run operations at regular intervals:
- Open Settings › Technical › Automation › Scheduled Actions.
- Create a new scheduled action.
- Configure the parameters: - a descriptive name; - the model concerned; - the Python method to run; - the frequency: daily, weekly and so on; - the next execution date.
- Enable the scheduled action.
Note
Scheduled actions are run by Odoo's task scheduler (cron). Make sure the cron service is properly configured on your server, so they run as they should.
Common uses
Scheduled actions are particularly useful for:
- generating recurring invoices;
- sending periodic reports;
- running month-end computations;
- synchronising data with outside systems;
- cleaning up or archiving old data;
- running replenishment computations;
- sending alerts about contracts or subscriptions approaching their end.
Notification rules
Configuring a notification
The same mechanism serves to notify users when certain conditions are met. The rule is built in the same place, with a notification as its action:
- Open Settings › Technical › Automation › Automation Rules.
- Create a new rule on the model concerned.
- Define the conditions under which it applies.
- Choose the action Send Email, Send SMS or Create Activity.
- State the recipients: users, teams or followers of the document.
- Enable the rule.
Typical use cases
Notification rules are particularly useful for:
- alerting on low stock;
- notifying late payments;
- flagging significant margin variances;
- alerting on blocked orders;
- notifying the creation of high-potential prospects;
- reporting new customers arriving in a strategic segment.
Communication templates
Email templates
Email templates standardise and automate your communications:
- Open Settings › Technical › Email › Email Templates.
- Create a new template.
- Configure the elements: - the name of the template; - the data model it applies to; - the subject of the email; - the body of the message, with dynamic variables; - the default attachments; - the sender and the recipients.
- Use variables to personalise the content.
- Test the template before using it in production.
Tip
Use the object.field_name syntax to insert dynamic variables into your email
templates. For instance object.name displays the name of the contact.
Automating communications
To automate the sending of communications:
- create email templates for each type of communication;
- attach them to automated or scheduled actions;
- configure the conditions for sending;
- for business processes, build the sending into the workflows.
Examples:
- a confirmation email when an order is created;
- a payment reminder for overdue invoices;
- a delivery notification with the tracking information;
- a request for feedback after a product or service is delivered;
- contract renewal alerts;
- targeted marketing communications.
Custom workflows
Designing workflows
To design an effective workflow:
- identify clearly the process to automate;
- list every step of the process;
- determine the conditions for moving from one step to the next;
- define the actions to run at each transition;
- identify the roles and responsibilities;
- document the workflow for future reference.
Note
Modelling your flow beforehand on paper or with a diagramming tool is strongly recommended, before implementing it in Odoo.
Implementing it in Odoo
In Odoo, workflows are generally implemented by combining:
- the states and stages of the document, that is the statuses in its life cycle;
- tracking fields: dates, responsible users, priorities;
- automated actions for the transitions;
- access rights to control who can approve each step;
- notifications and activities for the human follow-up.
An example, for an expense claim:
- the employee creates an expense claim (status: draft);
- an automated action notifies the manager for approval;
- the manager reviews and approves (status: approved);
- an automated action creates a task for the accounting department;
- the accountant checks the receipts and validates (status: validated);
- an automated action generates the payment;
- the treasurer makes the payment (status: paid);
- an automated action notifies the employee and closes the file.
Advanced automation
Odoo Studio (Enterprise)
With Odoo Studio, in the Enterprise edition, you can build automations with no code:
- add computed fields with formulas;
- create actions at interface level;
- customise the views and the processes;
- add custom action buttons;
- change the existing workflows.
Specific development
For highly specific automations:
- develop custom modules;
- write bespoke Python methods;
- implement custom triggers;
- interface Odoo with outside systems;
- use the Odoo API for advanced integrations.
Note
Specific development calls for technical skills in Python and a sound understanding of the Odoo framework. It should be carried out by experienced developers.
Outside integrations
API and web services
Odoo can integrate with outside systems through:
- a REST API (JSON-RPC);
- an XML-RPC API;
- webhooks for outgoing events;
- specific connectors for third-party applications.
Examples:
- synchronising with an outside e-commerce site;
- integration with payment systems;
- connecting to business intelligence tools;
- exchanging data with specialised business software;
- interfacing with electronic data interchange systems;
- synchronising with custom mobile applications.
Ready-made connectors
Odoo offers connectors for many third-party services:
- payment gateways (PayPal, Stripe, Adyen and others);
- delivery services (UPS, FedEx, DHL and others);
- marketplaces (Amazon, eBay and others);
- content management systems (WordPress, Shopify and others);
- communication tools (MailChimp, Twilio and others);
- social platforms.
Tip
Check the Odoo App Store for ready-made connectors before developing your own integration.
Good practice in automation
A methodical approach
To make a success of your automation projects:
- start by mapping your current processes;
- identify the inefficiencies and the bottlenecks;
- prioritise the automations by their impact and their complexity;
- proceed in stages, starting with the simple cases;
- test each automation carefully before going live;
- train the users on the new processes;
- measure the results and adjust where needed.
Pitfalls to avoid
A few common mistakes to avoid:
- over-automating processes that call for human judgement;
- building automations so complex they are hard to maintain;
- neglecting to document the automations put in place;
- implementing contradictory rules that interfere with one another;
- ignoring user training on the new processes;
- neglecting to test edge cases and exceptions.
Note
Build notification and follow-up mechanisms into your automations, so you can step in quickly when something goes wrong.
Monitoring and maintenance
To keep your automations working over time:
- put logging in place for the automated actions;
- review the logs regularly to spot anomalies;
- create alerts for automation failures;
- update the automations when the processes change;
- document every automation to make maintenance easier;
- adjust the automations in the light of user feedback.
Tip
Name an owner for each critical automation, responsible for watching it and keeping it working.