[FIX] avoid display root menus with no defined security groups

for Backend UI Users
This commit is contained in:
Clément Mombereau
2025-01-15 13:28:04 -03:00
parent b05b6bb0dd
commit 623676d784
7 changed files with 46 additions and 12 deletions

View File

@@ -0,0 +1,22 @@
# Copyright 2024 Akretion
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import api, models
class IrUiMenu(models.Model):
_inherit = "ir.ui.menu"
@api.model
@api.returns("self")
def get_user_roots(self):
"""Avoid to display root menus with no defined groups_id to Backend UI Users
like 'spreadsheet_dashboard.spreadsheet_dashboard_menu_root'
or 'base.menu_management'.
"""
res = super().get_user_roots()
if self.env.user.has_group("base_group_backend.group_backend_ui_users"):
return res.filtered(lambda m: m.groups_id)
else:
return res