|
|
@ -3,7 +3,7 @@ |
|
|
|
# |
|
|
|
# Cybrosys Technologies Pvt. Ltd. |
|
|
|
# |
|
|
|
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
|
|
|
# Copyright (C) 2025-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
|
|
|
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>) |
|
|
|
# |
|
|
|
# You can modify it under the terms of the GNU LESSER |
|
|
@ -20,7 +20,7 @@ |
|
|
|
# |
|
|
|
############################################################################# |
|
|
|
|
|
|
|
from odoo import fields, models, api |
|
|
|
from odoo import api, fields, models |
|
|
|
|
|
|
|
|
|
|
|
class ResUsers(models.Model): |
|
|
@ -36,11 +36,9 @@ class ResUsers(models.Model): |
|
|
|
for record in self: |
|
|
|
old_hide_menu_ids = old_hide_menu_map.get(record.id, |
|
|
|
self.env['ir.ui.menu']) |
|
|
|
|
|
|
|
# Add new restrictions |
|
|
|
for menu in record.hide_menu_ids: |
|
|
|
menu.sudo().write({'restrict_user_ids': [(4, record.id)]}) |
|
|
|
|
|
|
|
# Remove old ones that are no longer selected |
|
|
|
removed_menus = old_hide_menu_ids - record.hide_menu_ids |
|
|
|
for menu in removed_menus: |
|
|
@ -63,6 +61,21 @@ class ResUsers(models.Model): |
|
|
|
'be hidden to this user.') |
|
|
|
is_admin = fields.Boolean(compute='_get_is_admin', string="Is Admin", |
|
|
|
help='Check if the user is an admin.') |
|
|
|
is_show_specific_menu = fields.Boolean(string='Is Show Specific Menu', compute='_compute_is_show_specific_menu', |
|
|
|
help='Field determine to show the hide specific menu') |
|
|
|
|
|
|
|
@api.depends('groups_id') |
|
|
|
def _compute_is_show_specific_menu(self): |
|
|
|
""" compute function of the field is show specific menu """ |
|
|
|
group_id = self.env.ref('base.group_user') |
|
|
|
for rec in self: |
|
|
|
if group_id.name in rec.groups_id.mapped('name'): |
|
|
|
rec.is_show_specific_menu = False |
|
|
|
else: |
|
|
|
for menu in rec.hide_menu_ids: |
|
|
|
menu.restrict_user_ids = [fields.Command.unlink(rec.id)] |
|
|
|
rec.hide_menu_ids = [fields.Command.clear()] |
|
|
|
rec.is_show_specific_menu = True |
|
|
|
|
|
|
|
|
|
|
|
class IrUiMenu(models.Model): |
|
|
|