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 :-
Code for creating an Action and its MenuItem:-
<!-- Action for Student Information -->
<record id="action_student_information" model="ir.actions.act_window">
<field name="name">Student Information</field>
<!-- Top bar menu -->
<menuitem id="menu_college_main" name="College"/>
<!-- Left Sidebar MenuHead -->
<menuitem id="menu_student_main" name="Student" parent="menu_college_main"/>
<!-- Left Sidebar Menu -->
<menuitem id="menu_student_info" parent="menu_student_main" action="action_student_information"/>
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:-
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:-
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.