Server Actions

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):

  1. “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.
  2. “Share” allows you to create a link to the quotation / sales order

Automated Actions

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.

Scheduled Actions

Then we have a Scheduled Action (also called a cron job). They can only be used to call an existing method of a model (database table). You could create a new one (add-on module with Python code), but that’s out of the scope of this website.

For reference, this example is also for the Subscriptions app and 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 ir.actions.server model):

  1. Server Actions
  2. Automated Actions
  3. 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 (or executed from another Action).

Therefore the only reason to directly create a Server Action is if it will not be run automatically. For example:

As noted above, Scheduled Actions are something different.

Configuration of Server Actions and Automated Actions

  1. The action name should be descriptive
  2. All actions are related to a Model (database table)
  3. The options for Action To Do are the same as in Automated Actions
    1. Execute Python Code
    2. Create a new Record
    3. Update the Record
    4. Execute several actions
    5. Send Email
    6. Add Followers
    7. Create Next Activity
    8. Send SMS Text Message
  4. Usage is as described above (Server Action / Automated Action)
  5. 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

Contextual Actions

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)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s