Odoo Help

Welcome!

This community 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.

3

How to inherit or override a menu item

By
Eric
on 11/10/14, 8:01 PM 6,237 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?

4
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
1

Baiju

--Baiju--
3154
| 5 4 8
Kochi, India
--Baiju--
ODOO technical and functional

        I like learning new thing, especially technical thing. I am a quick learner, I can learn technical things very fast. I have good logical skill,  I have immense interest in programming.

e-mail id : baijuks@hotmail.com

Baiju
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"/>

 

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

2 follower(s)

Stats

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