Server Actions in Odoo

A server action is a defined action that can be triggered or run. What server actions are for.

Odoo has a way of defining an action, something that can be made to happen, separately from the place it is triggered. That is the server action. This piece is about server actions in Odoo.

What a server action is

A server action, in Odoo, is a defined action: a defined piece of behaviour, a defined thing that happens, that can be triggered or run. The server action defines what the action is, the thing to be done, as a defined, named thing in the system. Once defined, the server action can be triggered, made to happen, in various ways.

Why server actions are useful

Server actions are useful because they make an action a defined, reusable thing rather than something tied to one particular place. Because the server action defines the action separately, that defined action can be triggered from where it is needed, and it can be used by the things that make actions happen. A server action is, in effect, a flexible building block: a defined action that the rest of the system can trigger or run. This flexibility is why server actions are a useful part of a developer's toolkit, an action defined once and triggerable as needed.

What triggers a server action

A server action, being a defined action, can be triggered by the various things in Odoo that make actions happen. It can be triggered by a user, for instance through a means provided on a view. It can be run automatically, by the things that run actions automatically, the automated actions, the scheduled actions. So the server action is the defined "what should happen", and the various triggers, a user, an automation, a schedule, are the "when it happens". The server action and its triggers work together: the action is defined once, and triggered however it should be.

Server actions and the framework's flexibility

Server actions are part of how Odoo provides flexibility in making things happen. Together with the things that trigger them, server actions let a developer, and to an extent a configurer, define actions and have them happen at the right times, without that always requiring fresh code in every place. A developer should understand server actions as one of the building blocks Odoo provides for defining and triggering behaviour, and use them where a defined, triggerable action is what is genuinely wanted.

Use server actions for genuine, defined behaviour

An honest note. A server action should define a genuine, intended action, and be triggered for genuine reasons. As with all of Odoo's flexible mechanisms, a developer should use server actions deliberately, for genuine behaviour the business genuinely wants, defined clearly and triggered appropriately, not as a scatter of defined actions that is hard to keep track of. Used deliberately, server actions are a clean, flexible way to define and trigger behaviour.

The takeaway

Server actions in Odoo are defined actions, defined pieces of behaviour that can be triggered or run. They are useful because they make an action a defined, reusable thing rather than something tied to one place: the action is defined once and can be triggered from where it is needed, by a user, or run automatically by automated and scheduled actions. Server actions are a building block of Odoo's flexibility in making things happen, and a developer should use them deliberately, for genuine, defined behaviour. For how we approach Odoo, see our ERP practice.

All posts

Got a Topic Worth Posting?

Suggest a Topic

If a question keeps coming up in your operations, it might be worth its own post.