Odoo 16 Development Book

Python code server actions

Python code server actions are the most flexible kind of actions that helps users to meet their requirements through python code. It’s useful because of the capabilities to bring advanced logic to Odoo from the front end itself. Let’s have a look at the way in which the python code server actions are implemented;

After enabling the developer mode go to Settings > Technical > Automation > Automated Actions. Then create a new action.

For example, Let’s see how a warning is set on the record during creation.

odoo Development

This is a basic example to show the python code server actions. The fields that are used here;

Model: model upon which this action needs to be executed.

Action to do: type of action to be performed

Trigger: triggering conditions like on update, create, deletion, etc.

Apply on: condition specified before executing the action

Python Code: python code is explained here.

odoo Development

After saving the action, it will be necessary to add an email while creating any contact. Otherwise, it will show UserError according to the python code server action.

Automated actions on time conditions

Automated actions can be triggered based on time conditions. Thus if an operation needs to be performed at a specific time, then the automated actions are able to perform it.

Let’s see how this is implemented in Odoo;

Once you enable the developer mode, then go to the menu Settings > Technical > Automation > Automated Actions. Then let’s create a new record on that.

odoo Development

Model: Model on which the action needs to be performed.

Action To do: Select the type of action.

Trigger: Select the triggering type. Here it will be “Based on Time condition”

Apply on: conditions executed before the action

Email Template: email template to be used. It needs to be selected if the type is “send Email”

Trigger Date: it decides when the action should be triggered.

Delay after trigger date: it can have negative values so that the action will be triggered before the trigger date.

Automated actions on event conditions

Automated actions can be set to trigger the action based on a specific event. Let’s check if its working by using an example;

Let's consider that the user can update the project status only if they have access rights to the project manager and project leader. Now let’s create a server action based on a python code to show user error. It checks if the logged-in user and the project manager are the same or not. If it fails, then it will raise an error message.

odoo Development

Now let’s create another action for executing this action while on its update. It will be like this;

odoo Development

Here, The fields are explained like;

Model: The required model upon which the action will be performed.

Trigger: Triggering condition of the action.

Trigger fields: If any fields are mentioned, then the action will be based on the update on these fields.

Before update domain: If any conditions are mentioned here they will be satisfied before the update of the record

Apply on: If any conditions are specified on the field they will be satisfied before the action rule.

Action to do: The type of action is specified here.

After adding these requirements, when going to the project and trying to update the record, then, there will raise an error if the user is not the project manager for that particular project.

odoo Development


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