Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
4 Trả lời
6459 Lượt xem

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.

Ảnh đại diện
Huỷ bỏ

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

Câu trả lời hay nhất

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
Ảnh đại diện
Huỷ bỏ
Tác giả

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

Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 4 25
954
2
thg 7 23
5631
2
thg 11 19
3207
0
thg 9 19
5001
1
thg 3 15
5252