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
- Buchhaltung
- Lager
- PoS
- Projekte
- MRP
Diese Frage wurde gekennzeichnet
1
Antworten
3132
Ansichten
- 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?
Diskutieren Sie gerne? Treten Sie bei, statt nur zu lesen!
Erstellen Sie heute ein Konto, um exklusive Funktionen zu nutzen und mit unserer tollen Community zu interagieren!
Registrieren