Menu & Actions in Odoo 16

HARSHAD
April 21, 2023

Technical Odoo 16

This blog is to provide instructions on how to define menus and actions in Odoo 16. The Menus and Actions definitions in Odoo are flexible. As a first step, let’s see how to create a menu item in Odoo 16. Here, we can create a custom module called ‘Estate’.

define-menus-and-actions-in-Odoo-16I have created a custom module for this. After that, we will be able to add the first menu.

 <menuitem id="estate_menu_root" name="Estate" sequence="10"/>

Here are the steps we need to take to create a menu item record. We can specify the ID and name of a specific menu item here. In the UI, we will see a menu item with this name, and we can also assign it a serial number.

We can see a menu property under advertisement and the menu “Advertising” in the image above. We can then discuss how to create a similar menu.

<menuitem id="estate_menu_root" name="Estate"sequence="10"/><menuitem id="estate_first_menu_root" name="Advertisement" parent='estate_menu_root' sequence="8"/>

This code goes like this, that is, we have also discussed a menu item taken by ID and name before and we have also specified the parent attribute in this menu item tag. Since the first menu item is the “Estate” menu, and the second menu item is the “Advertisement”, we specified the first menu item’s id in the parent attribute of the second menu item.

Request Your Free Quote

parent-attribute-of-the-second-menu-item

The second menu can also have a menu called “Property”.Let’s see how we can create a menu under another menu.

<menuitem id="estate_second_menu_root" name="Properties"  parent='estate_first_menu_root' sequence="9"  action="estate_property_action"/>

The code of the menu object is noted above, it additionally takes the id, name, discern, and series attributes, with the discern being the second menu object. Here, we also can specify any other characteristic that’s actions. The action attribute specifies what action should be performed when the menu item is selected.

action-attribute-specifiesClicking the menu object takes you to a tree view of the model “estate.property ”.

Currently, I have added a model and created a form and tree views. We need to define the act window record for the particular model.

<record id="estate_property_action" model="ir.actions.act_window">

<field name="name">Properties</field>

<field name="type"> ir.actions.act_window"</field>

<field name="res_model">estate.property</field>

<field name="view_mode">tree,form</field></record>

The window action is created in template ir.actions.act_window. Here we can specify the ID of the general record act_window, in the template name field we will specify the name of the record act_window, and in the type field, we can specify the IR action.

Act_window, the rest of the model fields will specify the model whose view will open even as this unique menu item is clicked, then in the view mode field specify the particular view that should open when a particular menu item is clicked – click. The action attribute is placed inside the menu item by putting the id of Actions. By doing so, we can provide actions for a menu item.

We can then see the user interface. The tree view will open when you click the menu item.

odoo-menu-itemClicking on a specific line object will open the shape view for that object.

Odoo 16 allows us to define or create menu items and actions this way.

DOWNLOAD ERP

"Unlock the Full Potential of Your Business with Odoo ERP!"

"Get a Cost Estimate for Your ERP Project, Absolutely FREE!"

Get a Free Quote

Leave a Reply

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