Help

1

[11.0] How Hide Menu Item for the Specific Users in a Group

Hi to Everyone,


I have three Users in a Group like User 1, User 2, User 3 in Delivery Group and also i'm having the Separate Model to show this menu item to this User only.

For Ex.

Name    Rights

User 1    True

User 2    False

User 3     True

Here i need to Hide Delivery Menu to User 2 only and I'm unable to create separate Groups for User 1, User 3 and User 2. Because values will be change based on User Performance.

For Ex. After three months 

Name    Rights

User 1    True

User 2    True

User 3     False

Now i want to show Menu item to User 1 and User 2 only, Not to User 3

Thanks in Advance.

1 Comment
Avatar
Discard
Avatar
Sehrish
-

Hope these customization tips will help you: http://learnopenerp.blogspot.com/

1 Answer
8
Avatar
Ashish Singh
Best Answer

Hi, Gokulakrishnan

Yes, there is a way to achieve above requirement(Without creating using group).

Inside "Menu" class there is a method "_visible_menu_ids" which helps to show menu at Odoo end. So you can prepare logic like below,

class Menu(models.Model):
_inherit = 'ir.ui.menu'
@api.model
@tools.ormcache('frozenset(self.env.user.groups_id.ids)', 'debug')

def _visible_menu_ids(self, debug=False):
menus = super(Menu,self)._visible_menu_ids(debug)
if Yourcondition:
menus.discard(self.env.ref("model.menu_id").id)
                return menus
Yourcondition : Add you condition as per your requirement
menu_id           : Add the menu id which you want to hide

Hope above method will help to you achieve your requirement.

Thanks,
Ashish Singh(Team Lead)
Webkul Software Private Limited
2 Comments
Avatar
Discard

Hey Man, Thanks a lot. You saved my day.

Avatar
Ashish Singh
-

Hi, Gokulakrishnan

Thanks for your kind words.It was really great of you to trust my assistance

Thanks,

Ashish Singh(Team Lead)

Webkul Software Private Limited