Menu Inheritance in Odoo

how to Menu Inheritance in Odoo.

This blog is about how to Menu Inheritance in Odoo.Many times we develop custom module but we get in a dilemma that how we can modify the attributes for existing menu items. What we would like to do is remove the original menu item so that users in that group can’t see it. So to achieve this in Odoo we need to inherit the original menu item in our custom module and modify the attributes as per our needs.

Now, Let’s see how we can bring it in a custom module.

Firstly, You might be knowing that menu entries are usually defined with the ‘menuitem’ XML tag.
i.e.

<menuitem name=”menuName” id=”menu_id” … />

You got menuitem then you can easily inherit and make it compatible as per your requirements.
Like,

  1. Adding New Attributes.
  2. Removing Old Attributes.
  3. Modifying Existing Attributes.

To redefine menu item you don’t need xpath, simply redefine that in your XML file, with correct id reference.

You just have to add original module name followed by “.”(Dot) followed by original menuitem ID.

Syntax :

<menuitem id=”module_name.menu_id” name=”menuName” … />

Example:

Original:

<menuitem name=”Human Resources”
id=”menu_hr_root”
groups=”base.group_hr_manager,base.group_hr_user,base.group_user”
sequence=”90″/>

you can evict the group from Human Resources menuitem like this:-

Inherited:

<menuitem name=”Human Resources”
id=”hr.menu_hr_root”
sequence=”90″/>

That’s It.

You must be logged in to post a comment.