Hello, I have one custom module icon on my odoo 15 navigation bar here I want that only admin can view this icon the other user can not view this icon. how to do this.
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project management
- MRP
This question has been flagged
1
Reply
1967
Views
- Create An Empty module or you have any other module which depends on base
- In Module inherit the model ir.ui.menu and override this function
from odoo import api, models
class IrUiMenu(models.Model):
_inherit = 'ir.ui.menu'
@api.model
def search(self, args, offset=0, limit=None, order=None, count=False):
context = self._context or {}
if not self.env.user.has_group('base.group_system') and context.get('hide_non_admin_icons'):
args = [('icon', '=', False), ('groups_id', '=', False)] + args
return super(IrUiMenu, self).search(args, offset=offset, limit=limit, order=order, count=count)
- In your desired view, add the following line in the context to hide the icons:
{'hide_non_admin_icons': True}
Thanks for your reply but the custom icon is added with an inherited template, in that case, how can I add context to it?
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign up