Learn – How to create a Window Action and Menuitem in Odoo 8 with Example

Greetings Everyone,

In this blog-post tutorial, you will learn how to create an Action and its Menuitem in an Odoo 8 module.

Type of Actions in Odoo:

  • Window Actions (ir.actions.act_window)
  • URL Actions (ir.actions.act_url)
  • Server Actions (ir.actions.server)
  • Report Actions (ir.actions.report.xml)
  • Client Actions (ir.actions.client)

Here we’ll learn about the Window Action.

What is Window Action in Odoo?

  • Window Actions are used to present visualisations of a model through views.
  • A window action defines a set of view types (and possibly specific views such as Tree, Form, Search) for a model (and possibly specific record of the model).

Example of Action and Menuitem :-

Earlier in my previous blog-posts, I created a student model, then I created its Form View followed by Tree View.  Now in this tutorial, I will create Action and Menuitem for it.

Code for creating an Action and its MenuItem:-

Steps for creating Action:-

  • Window actions are stored in database table ir_act_window. So first, write record tag and give unique id and ir.actions.act_window model. See the above code for reference.
  • Next, the string given in ‘name’ will appear on the menuitem (if the string is not provided in menuitem). Here I have given ‘Student Information’.
  • Further, very important, provide your model name in ‘res_model’. This will link your action with your model. Here I have given ‘student.student’.
  • ‘view_mode’ will give sequence to your views. Here tree and form view will be displayed first and second, respectively.
  • When is action called? The action is called when you click on its related menuitem.

SnapShot of Eclipse IDE:-

Action-in-Odoo
Action-in-Odoo – Click to Enlarge

Steps for creating Menuitem:-

  • Menuitems are created by <menuitem> tag
  • Provide unique id in ‘id’.
  • Provide the id of the parent menu in ‘parent’. Here i wanted to show ‘Student’ under ‘College’, so I wrote the id of ‘College’ menuitem in ‘Student’ menutiem.
  • Write the id of the action just created above inside ‘action’ attribute. Here, ‘action_student_information’.

SnapShot of created Menuitem:-

Menuitem-tutorial-odoo-8
Menuitem-tutorial-odoo-8 – Click to enlarge

Hope you learnt how to create an Action and Menuitem in Odoo module in this tutorial, your reviews/comments/suggestions/doubts are most welcomed, please comment in the section below, and subscribe to the newsletter to receive timely future updates of this blog..

I will update how to create Search view soon.

Thank You.

 

Myself, Burhan Vakharia, am an Odoo developer, CS Lover living in Gandhinagar, Gujarat, India. I have a degree in Computer Science and Engineering from Babaria Institute of Technology. I am currently working as Odoo Developer. Apart from Odoo Framework, I have worked on C# .Net and Android Platforms. You can contact me via my social profiles shown below.

Post Author: Burhan Vakharia

Myself, Burhan Vakharia, am an Odoo developer, CS Lover living in Gandhinagar, Gujarat, India. I have a degree in Computer Science and Engineering from Babaria Institute of Technology. I am currently working as Odoo Developer. Apart from Odoo Framework, I have worked on C# .Net and Android Platforms. You can contact me via my social profiles shown below.

1 thought on “Learn – How to create a Window Action and Menuitem in Odoo 8 with Example

    iqra

    (April 3, 2018 - 6:00 am)

    great article for beginners, thanks sir

Leave a Reply

Your email address will not be published. Required fields are marked *