Development Book V17:Create server actions

Server actions are those actions that work on a base model and offer various types of actions that can be executed automatically.

After enabling the developer mode, navigate to the Settings > Technical > Actions > Server Actions.

Let’s check the server action types;

1. Update Record

2. Create Record

3. Execute Code

4. Execute Existing Actions

5. Send Email

6. Send SMS

7. Add Followers

8. Remove Followers

9. Create Activity

10. Send Webhook Notification


This is the form view for creating a new server action, add the name and choose the model for which this action will be executed.Also select the action type.

XML code for creating a server action. It is placed in the data file of the module.

 <record id="action_set_salesperson" model="ir.actions.server">
 <field name="name">Set Sales Person </field>
 <field name="model_id" ref="base.model_res_partner"/>
 <field name="state">code</field>
</record >

In this code, the ‘model_id’ used to mention the model to which this action is executed. Next is the ‘state’ field that is used for specifying the type of server action.

Let’s go through the type of server actions;

Update Record

This type of server action is created to perform updates on a specified model.

For example, If we need to set anyone as the salesperson for the records of contact, create a server action like this;


Here, the action type is chosen as Update Record and the model_id is selected as contact so this action will be available for the records of the contact model.Under the section Action Details choose the field and the value needed to be updated.

Click on Create Contextual Action to create this server action. As a result, you will get a new menu in the contextual action in the view as given below.


Clicking the option triggers the assignment of the value to the salesperson field through the server action, facilitating the update of the record.

In the code, the update can be done as;

 <field name="state">object_write</field>

Create Record

These types of actions are used to create records in the specified model.


Specify the model, target model and the field to generate.

Execute Code

This type of server action is used to execute python code


This can be done in the code as follows;

< field name="state">code

Execute Existing Actions

This server action type allows the execution of multiple actions simultaneously. Users can select the specific actions to be performed collectively.


After creating the action, the listed child actions will be executed simultaneously when this action is selected. This type of action is declared in the XML as;

< field name="state">multi

Send Email

This is used to send emails to partners from a specified model.


We can select the mode of sending, either it can be sent as an ‘Email’ or ‘Message’ or ‘ Note’. In code;

 < field name="state">mail_post</field> 

Send SMS

This is used to send SMS to partners from a specified model.


We can select the mode of sending SMS, either it can be sent as an ‘SMS (without note)’ or SMS (with note) or ‘ Note only’. In code;

< field name="state">sms

Add Followers

This is used to add followers to the records of the specified model.


When this action is executed these partners will be added as followers to the record in the specified model.

In xml the code is as;

<field name="state">followers</field>

Remove Followers

This is used to remove followers from the records of the specified model.


In the xml,

 <field name="state">remove_followers</field>

When this action is executed the partner/partners will be removed from followers of the record in the specified model.

Create Activity

These types of actions are used to schedule the activities based on a model.


This will create a contextual action to schedule the action specified onmodel.

In xml, the code follows as;

<field name="state">next_activity</field>

Send Webhook Notification


A webhook notification is a mechanism for two systems to communicate in real-time by sending HTTP POST requests to a predefined URL (endpoint) when a specific event occurs. Provide the URL of the endpoint and the fields needed to be included in the request.



Cybrosys Technologies Pvt. Ltd.
Neospace, Kinfra Techno Park
Kakkancherry, Calicut
Kerala, India - 673635



Cybrosys Technologies Pvt. Ltd.
1st Floor, Thapasya Building,
Infopark, Kakkanad,
Kochi, India - 682030.



Cybrosys Techno Solutions
The Estate, 8th Floor,
Dickenson Road,
Bangalore, India - 560042

Send Us A Message