Globalteckz

Different Types of Actions in Odoo

  • Home
  • Different Types of Actions in Odoo
various types of actions in odoo

Different Types of Actions in Odoo

In this blog post, we are going to know about the different types of actions in odoo 13. Actions are done by the users and the system gives some response based on user action, these responses are actually known as actions. Actions in Odoo ERP actually defines the behavior of the system in response to user actions for example : a login done by the user, action button, selection of an invoice, and so on…

There are a various number of actions in Odoo ERP software which is as follows:

1) Server Actions (ir.actions.server)

2) Window Actions (ir.actions.act_window)

3) URL Actions (ir.actions.act_url)

4) Client Actions (ir.actions.client)

5) Report Actions (ir.actions.report)

6) Automated Actions (ir.cron)

All these actions are stored in the database and when we call a method like a button method which refers to actions it returns directly as dictionaries.

We can see all user-defined actions from Settings -> Technical -> Actions.

creating actions in Odoo from settings

In the action creation form, there are two mandatory char fields are there.

  1. Name: Name of the action, it display on the client interface.
  2. Action Type: Action type is Where we define the type or category of the current action.

These are the two mandatory attributes and we have a number of optional argument are like,

res_model, binding_model_id, binding_view_types, view_id, view_ids, view_mode, view_type, search_view_id, state, code, domain, context, target etc.

  1. Server Actions (ir.actions.server)

This odoo action triggers the server code. It is helped to execute various types of actions automatically.

The available server actions are :

* Execute Python Code: Written python code that will be executed

* Create a new Record: Create a new record with values.

* Write on a Record: Update the record values.

* Execute several actions: Which trigger several server actions.

model_id : Model refers to this action.

binding_model_id : It defines which model is bound to this action.

binding_view_types : Mostly list / form is used to represent this field.

state: Options are,

code: Executes python code given in the argument  of code.

* object_create: It creates a new record.

object_write: Update the current record.

multi: Executes several actions given in the argument of child_ids.

code: Used to write python code and execute this code when the action is occur.

Example

xml:

server actions in Odoo erp

This will execute the method action_test_code() in the model test model.

For more details you can refer How to Create Server Actions in Odoo blog.

  1. Window Actions (ir.actions.act_window)

This is the most common type action, it triggers a different view of the model and in other words it is  used to visualize the models with different types of views.

xml:

res_model : Model for representing this action window.

res_id : It is used to pass the active id of res_model.

view_mode : List of view types separated by commas(no spaces), ie, kanban, tree, form.

view_id : Provide the default view type will be open when the action is executed. If there is nothing it will open the window with the view of first type in the view_mode.

view_ids : We can define specific views for specific view_mode.

search_view_id : Setting the default search view for the object.

context : Used to pass additional context data passed to view.

domain : Condition used to filter the data passed to view.

target : We can define different options for target windows.

* new : It opens a window with a new address and edit mode(as when creating wizards) .

current : It opens the regular form views.

* fullscreen : It will open the window in fullscreen mode.

main : Without breadcrumb, it opens the main content area.

inline : It will open the window in edit mode.

Example: A wizard will open while clicking a button.

py:

py file action in odoo

  1. URL Actions (ir.actions.act_url)

This action used to open a URL(website/web page).

xml:

url actions in odoo

py :

There is two important customized fields are,

url : The opened url when activating the action.

target : Types of target windows for url action.

* self : It opens the current window with current content.

* new : It redirects to the address with a new window.

  1. Client Actions (ir.actions.client)

It triggers the client implemented actions.One can create client actions as per our needs. Basically these actions are defined as menu_items in xml and it mapped to a widget.

Example:

Xml:

client actions in odoo

Then we need to create a widget in js with name as pdf_report_page.

tag: Which is an arbitrary string for which the client can identify the action.

params : It is a python dictionary with additional data to the client.

target: Options are,

current : It opens the main content area.

new: It will open a window  like dialog/popup.

fullscreen: It will open a window in fullscreen mode.

main: It will open the main content area without breadcrumbs.

  1. Report Actions (ir.actions.report)

It mainly triggers the printing of Report action.

reports actions in odoo

name : Name of report action.

Model : The model of report will be about.

report_type : qweb-html and qweb-pdf (for HTML and for PDF reports )

report_name : Report name.

groups_id : Group allowed for the current report.

paperformat_id : Field to specify the paper format for the report. It is a many to many field.

attachment : Where we can define a python expression(name of the report).

attachment_use : It is set to true when the reports must be generated once and we can reprint the stored report instead of generating every time.

Example: A button with ‘ir.actions.report’ type returns a dictionary. The name of the report referred by report_name and data of the current record is stored in the variable named datas.

report actions in odoo erp

Example: A button with ‘ir.actions.report’ type returns a dictionary. The name of the report referred by report_name and data of the current record is stored in the variable named datas.

About Globalteckz:

At Globalteckz we offer our clients with world class Business and Enterprise solutions. We are presence in India, USA, &  Canada, and have successfully offered end to end solutions to our clients. Some of our services offering include leading Open Source Solutions such as Odoo, Magento, and others ecommerce development. We deliver excellence and quality for Information Technology & Software Solutions to our clients worldwide.

For questions on Odoo pricing and cost that can involve with your business you can contact our sales team on sales@globalteckz.com

Read more articles related to Odoo Pricing :

Leave Comment

×