Chapter 6 - Odoo 15 Development Book

Menu Action

You can use menus for navigating to different pages. In Odoo, you can create menus from the code as well as from the user interface.

From the code, you are using XML for adding menus and their actions. So first, you want to create a new XML file inside the views folder.


You can use the menuitem tag for creating a new menu. The attribute name is for how to display the name of the menu. And you can specify the sequence for the menu, and sequence means in which position you want to display the menu. The menu item will display only if there is an action for it or if any of the submenu has an action.

For example:

<menuitem id="menu_hospital_patient_root" name="Hospital Management" sequence="3"/>

Sub Menu

You can create a submenus for the main menu. For creating submenu, a parent menu is required.

For example:

<menuitem id="menu_hospita_menu" name="Hospital" sequence="3" parent="menu_hospital_patient_root"/>

<menuitem id="menu_patient_menu" name="Patients" action="hospital_patient_action_main_tree" sequence="3" parent="menu_hospita_menu"/>

Two submenus are here. Hospital submenu is under the main menu Hospital Management and Patients is under Hospital menu. Patients menu has an action, so when clicking the menu goes to the corresponding action.


Next is to define the action. The menu or its submenu should have an action for viewing the menu.

For Example:

<record id="hospital_patient_action_main_tree" model="ir.actions.act_window">
<field name="name">Patients</field>
<field name="res_model">hospital.patient</field>
<field name="view_mode">list,form</field>
<field name="help" type="html">
<p class="o_view_nocontent_smiling_face">No patients found. Let's create one!</p>
<p>To get things done, use activities and status on patients.</p>
</field> </record>

From the action:

name: Name of the action

res_model: Name of the action

view_mode: The mode of the view, Here list and form are the view modes. And must want to create corresponding views for the view modes.

Help: If there is no data then will display the message inside the help.

Menus from The UI:

is also possible to create and edit the menus and submenus from the user interface. For that, Go to > Settings > Technical > User Interface > Menu Items.


For creating a menu from the UI, Go to > Menu Items > Create


Here to create a menu in the new module hospital_management,

Menu - Name of the menu

Parent Menu - The parent menu

Sequence - Sequence of the menu item.

Action - Specify the action.

Access Rights - - If you want to give access only to a particular user group, you can give access rights.

Submenus - - If you want to add a submenu for the menu, you can add it here.

After saving the form, go to the corresponding module, and now you can see the menus.


Here Report is the newly added menu. This way, you can create new menus and submenus from the UI.



Cybrosys Technologies Pvt. Ltd.
Neospace, Kinfra Techno Park
Kakkancherry, Calicut
Kerala, India - 673635



Cybrosys Technologies Pvt. Ltd.
1st Floor, Thapasya Building,
Infopark, Kakkanad,
Kochi, India - 682030.



Cybrosys Techno Solutions
The Estate, 8th Floor,
Dickenson Road,
Bangalore, India - 560042

Send Us A Message