Server Actions are one form of automation in Odoo. They provide a simple way to execute an action against a Model (database table). There are many different types of action and they can be executed automatically or manually.
It’s probably easiest to understand them by looking at examples.
Enable developer mode and navigate to Settings / Technical / Server Actions
The first two examples are both for Quotations and Sales Orders (sale.order), and both are available from the Action menu (for Quotations):
- “Send a Cart Recovery Email” is used in eCommerce and will send an email to a customer who has added items to a shopping cart but not completed the purchase.
- “Share” allows you to create a link to the quotation / sales order
The next Server Action is for the Subscriptions app. This is an Automated Action, meaning that it will be triggered based upon rules (in this case a satisfaction score of less than 30%, 1 month after the start of the subscription).
The “action” is to to schedule a call, and this will be assigned to the user who created the subscription.
Then we have a Scheduled Action, also for the Subscriptions app. This will generate recurring invoices and payments related to subscriptions, and as standard is run once per day. This should ensure that you can invoice your customer at the right time (without having to remember).
So we have three different usage types (all stored in the
- Server Actions
- Automated Actions
- Scheduled Actions
The only difference between between an Automated Action and a Server Action is that:
– Automated Actions have rules that define how they are triggered.
– Server Actions can only be executed manually.
The only reason to directly create a Server Action is if it will not be run automatically. For example:
- The action name should be descriptive
- All actions are related to a Model (database table)
- The options for Action To Do are the same as in Automated Actions
- Execute Python Code
- Create a new Record
- Update the Record
- Execute several actions
- Send Email
- Add Followers
- Create Next Activity
- Send SMS Text Message
- Usage is as described above (Server Action / Automated Action / Scheduled Action)
- Binding Model is not shown as standard, but it’s easy to add with Odoo Studio. If it is set (and it will always be the same Model) it means this is a Contextual Action
You can select any of the three types of Server Action listed above and click on the “Create Contextual Action” button. This makes them available on the “Action” menu on both List Views and Form Views.
See this example for more details
You can review all the standard Server Actions to better understand how they are used (navigate to Settings / Technical / Server Actions)