Creating Server Actions in Odoo 13

Creating Server Actions in Odoo 13

Sulabh Chauhan

April 11th, 2020

Server actions like creating a record, executing several actions, etc. can enable customers to meet their requirements in Odoo 13. So, let’s understand this functionality in detail and how to use various parameters in server actions accordingly.

Before we proceed to discuss all server actions in detail, it is important to understand what server actions actually are.

Server Actions: Definitions and Types

Server actions are actions that can be executed automatically. As an Odoo admin, under the ‘Technical’ menu comes the Actions -> Server Actions option. However, for the ‘Technical’ menu to be visible, you need to activate the ‘Developer’ mode first.

To activate the ‘Developer’ mode, refer to this screenshot.

New - Odoo

After activating the ‘Developer Mode’, you will find the ‘Server Actions’ menu.

Server Actions - Odoo

If you use any Odoo 13 theme or app, you can define a server action for a complex and long task like “Product Website Published.”

There are two ways to create a server action.

– Using code

– Using user interface (GUI)

Below are some available server actions:

– Update the record

– Create a new record

– Execute Python code

– Execute several actions

– Send Email

– Add Followers

– Create the next activity

– Send SMS

Though all of these server actions are quite important, one of the server actions that you often need to create is ‘Update the Record’. Let’s understand this server action in detail and how to use it. 

Following that, we will explain the rest of the server actions in brief as well.

Update the Record

Let’s take a real-life scenario to understand the use of this server action. 

If you handle a website that has lots of products and wish to publish all the products in one go, you can simply define a server action with “Update the Record”.

Now, create a record for ‘Server Actions’.

Add the following details:

– Model – Model linked to the action

– Action to do – Select the action ‘Update the Record’

– Field – Specify the field you need to update.

– Evaluation Type – This is the type to be updated and is of three types – value, reference and python expression 

– Value – It specifies the ‘Value’ field as a literal value.

– Reference – Allows you to select the existing values in the ‘Record’ field.

Now add your server action to the related object via the ‘Create Contextual Action’ button. After you add this button, you will see that the menu appears under the ‘Action’ button of the related objects. In this case, the related object will be “Products”.

 

Below are the several other types of server actions that you can create similarly:

Send Email: Using this server action, you can send emails to your partners.

Add Followers: Using this server action, you can add followers and channels.

Execute Python: Using this server action, you can execute a block of python code.

Send SMS/Text Message: Using this server action, you can send text messages in bulk to your business partners and customers.

Create Next Activity: Using this server action, you can create the next activity. For instance, if you have a meeting with a client, you can create an activity ‘Meeting’ and specify its due date.

Execute Several Actions: Using this server action, you can perform several server actions at a time.

Create a New Record: Using this server action, you can create a new record. But for that, you need to specify the model you want to create the record in.

In a Nutshell

Defining server actions in an Odoo 13 theme or app helps users create or update a  record, create an activity, etc. enabling them to meet their requirements.

All product and company names are trademarks™, registered® or copyright© trademarks of their respective holders. Use of them does not imply any affiliation with or endorsement by them.

 

Read Related Blogs About Odoo

Odoo Apps and Themes – To Keep Your Odoo Store Productive

Odoo Apps and Themes – To Keep Your Odoo Store Productive

4 Min
Lightning Strikes Here: Odoo Theme Scita is AMP Ready

Lightning Strikes Here: Odoo Theme Scita is AMP Ready

3 Min
Odoo Multi Themes Support: A Powerful Feature

Odoo Multi Themes Support: A Powerful Feature

3 Min