Server actions

One of the lesser-known features of Odoo is "Server Actions." These actions allow you to automate repetitive tasks and perform complex operations with minimal manual intervention, significantly improving any company's operational efficiency.

What are Server Actions?

Server Actions in Odoo are scripts that run on the server and can be configured to perform specific tasks in response to certain events or conditions. These actions allow users to:

  1. Update records
  2. Create related records
  3. Send notifications via email or SMS
  4. Add followers
  5. Create activities
  6. Execute complex code

To use them, simply select the records, and the actions will appear in the Actions menu.

How do we create them?

To create them, you need to access developer mode and go to the menu Settings > Technical > Actions > Server Actions. From there, you can create the actions you want.


Depending on the action to be performed, you will be asked for different necessary information to execute all the tasks.

To have it appear in the menu, you need to click on the Create contextual action button, which will make the action visible.

Executing Python Code

Among the various options when creating the action, you can select Execute Python Code. Although it is functional and very interesting, it is always recommended not to do it through the interface because, during migrations, this code might stop working. For this reason, we recommend that more complex actions be in modules that allow testing and updating the actions during migrations.

Automated Actions

Within Odoo, there is a very similar concept known as automated actions. These actions only appear if we install the base_automation module. They have a configuration similar to server actions, but they execute automatically when actions occur on the records:

  • Creation of a record
  • Update of a record
  • Update of specific fields
  • Deletion of a record

To edit them, we need to go to the menu Settings > Technical > Automation > Automated Actions.

Scheduled Actions

Finally, there is a similar type of record called scheduled actions. They are very useful for managing repetitive tasks within our instance. Additionally, Odoo itself configures several important actions, such as automatic email reception. However, these actions only allow the execution of Python code.

Conclusions

Server Actions in Odoo are a tool to automate and optimize business processes. They save time and reduce manual errors, significantly improving operational efficiency.


Dixmit in Jornadas Odoo at Tenerife