Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
4 Відповіді
6445 Переглядів

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.

Аватар
Відмінити

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

Найкраща відповідь

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
Аватар
Відмінити
Автор

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

Related Posts Відповіді Переглядів Дія
1
квіт. 25
922
2
лип. 23
5625
2
лист. 19
3176
0
вер. 19
4983
1
бер. 15
5247