Skip to content

Commit

Permalink
[IMP] portal_backend: Assert all parent menus has internal group
Browse files Browse the repository at this point in the history
  • Loading branch information
bruno-zanotti committed Oct 4, 2023
1 parent 917fe47 commit c28a8e1
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 9 deletions.
3 changes: 1 addition & 2 deletions portal_backend/__manifest__.py
Original file line number Diff line number Diff line change
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 All @@ -32,7 +32,6 @@
'data': [
'security/res_groups.xml',
'security/ir.model.access.csv',
'views/base_menus.xml',
'views/portal_templates.xml',
],
'demo': [
Expand Down
1 change: 1 addition & 0 deletions portal_backend/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
from . import ir_http
from . import mail_thread
from . import mail_activity_mixin
from . import ir_ui_menu
1 change: 1 addition & 0 deletions portal_backend/models/ir_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def session_info(self):
# to avoid access errors and unnecessary information, it is only included for users
# with access to the backend ('internal'-type users)
menus = request.env['ir.ui.menu'].load_menus(request.session.debug)
import pdb;pdb.set_trace()
ordered_menus = {str(k): v for k, v in menus.items()}
menu_json_utf8 = json.dumps(ordered_menus, default=ustr, sort_keys=True).encode()
session_info['cache_hashes'].update({
Expand Down
14 changes: 14 additions & 0 deletions portal_backend/models/ir_ui_menu.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from odoo import models, Command


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

def load_menus(self, debug):
""" Assert all parent menus has internal group
"""
parent_menus_wo_group = self.search([('parent_id', '=', False), ('groups_id', '=', False)])
parent_menus_wo_group.write({
'groups_id': [Command.link(self.env.ref('base.group_user').id)]
})
return super().load_menus(debug=debug)
7 changes: 0 additions & 7 deletions portal_backend/views/base_menus.xml

This file was deleted.

0 comments on commit c28a8e1

Please sign in to comment.