Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
4 Risposte
6453 Visualizzazioni

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.

Avatar
Abbandona

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

Risposta migliore

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
Avatar
Abbandona
Autore

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

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

Post correlati Risposte Visualizzazioni Attività
1
apr 25
932
2
lug 23
5627
2
nov 19
3194
0
set 19
4991
1
mar 15
5248