Skip to content

Commit

Permalink
[FIX] portal_backend: override load_menu as superuser to avoid person…
Browse files Browse the repository at this point in the history
…alization restrictions

closes #143

Signed-off-by: Juan José Scarafía <jjs@adhoc.com.ar>
  • Loading branch information
Bruno-Zanotti committed Nov 30, 2023
1 parent ed68ba1 commit a3c94c1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion portal_backend/__manifest__.py
Expand Up @@ -19,7 +19,7 @@
##############################################################################
{
'name': 'Portal Backend',
'version': "16.0.1.1.0",
'version': "16.0.1.2.0",
'category': 'Base',
'sequence': 14,
'summary': '',
Expand Down
13 changes: 8 additions & 5 deletions portal_backend/models/ir_ui_menu.py
@@ -1,14 +1,17 @@
from odoo import models, Command

from odoo import models, Command, tools

class IrUiMenu(models.Model):
_inherit = 'ir.ui.menu'

@tools.ormcache_context('self._uid', 'debug', keys=('lang',))
def load_menus(self, debug):
""" Assert all parent menus has internal group
""" Assert all parent menus has internal group.
"""
parent_menus_wo_group = self.search([('parent_id', '=', False), ('groups_id', '=', False)])
parent_menus_wo_group.write({
# NOTE:
# It is important to do it here to capture the case when portal_backend is already installed and the user
# installs another module with a parent menu without internal group.
parent_menus_wo_group = self.sudo().search([('parent_id', '=', False), ('groups_id', '=', False)])
parent_menus_wo_group.with_context('install_mode').write({
'groups_id': [Command.link(self.env.ref('base.group_user').id)]
})
return super().load_menus(debug=debug)

0 comments on commit a3c94c1

Please sign in to comment.