Odoo Help

3

How to inherit or override a menu item

By
Eric
on 11/10/14, 8:01 PM 9,396 views

Hello,

   I created a custom hr module and was wondering how I can modify the groups attribute for the top Human Resources menu item.  What I would like to do is remove one of the groups on the original menu item so that users in that group cant see it.  Is there a way to inherit the original menu item in my custom hr module, and use xpath to modify it? Or is there another (easier) way to do it?

6
Marvin Taboada
On 11/10/14, 11:24 PM

Hello Eric, menu entries are usually defined with the 'menuitem' XML tag (e.g. for Project>Configuration see this link):

<menuitem name="menuName" id="mod_id.menu_id" ... />

At installing the module, however, they are stored as records of the 'ir.ui.menu' object type. where the many2many relationship to 'res.groups' is defined.

Given that, it is perfectly possible to use 'record' XML tags to update 'ir.ui.menu' records by providing 'model' and 'id' attributes to identify the existing record. E.g. Project>Configuration (source here):

<record model="ir.ui.menu" id="mod_id.menu_id">
  <field name="groups_id" eval="[(6,0,[ref('group_my_restricted_group')])]"/>
</record>

Just remember 'groups_id' is a many2many relationship, so you will require to provide an appropriate tuple to update the relationship (the above example replaces all groups). Look for the documentation of 'write(vals)' here for a reference.

Regards,

Marvin

This is a very simple solution. Thank you!

Eric
on 11/11/14, 11:20 AM

I didn't quite understand that. Let's say I would like to add a sub-menu to Sales/Sales, what I did was to write the following code in my custom module:

<menuitem name="Daily Transports" id="daily_transports_menu" sequence="10" parent="base.menu_base_partner" action="daily_transports_action"/>

but I didn't get it to appear under the sales submenus

Demian Rihs
on 1/10/17, 7:22 PM
1
Baiju KS
On 11/10/14, 11:18 PM

To redefine menu item you don't need xpath ,, simply redfine that in your xml file,, with correct id reference ,, here change  id as " hr.menu_hr_root"

Orginal:-

<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 group from Human Resources menuitem like this:-

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

 

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)

Stats

Asked: 11/10/14, 8:01 PM
Seen: 9396 times
Last updated: 8/12/15, 10:44 AM