Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][IMP] base_group_backend: allow read on calendar.event and remove Dashboard menu for backend users #326

Open
wants to merge 2 commits into
base: 16.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion base_group_backend/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"base",
"base_install_request", # weird module, we need to survive with it
"mail",
"calendar",
],
"maintainers": ["FranzPoize", "bealdav"],
"demo": [
Expand All @@ -23,7 +24,6 @@
],
"data": [
"data/res_groups.xml",
"data/ir_ui_menu.xml",
"security/ir.model.access.csv",
],
"installable": True,
Expand Down
8 changes: 0 additions & 8 deletions base_group_backend/data/ir_ui_menu.xml

This file was deleted.

1 change: 1 addition & 0 deletions base_group_backend/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
from . import res_users
from . import ir_ui_menu
22 changes: 22 additions & 0 deletions base_group_backend/models/ir_ui_menu.py
Original file line number Diff line number Diff line change
@@ -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 roots 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
4 changes: 2 additions & 2 deletions base_group_backend/models/res_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ def has_group(self, group_ext_id):
"base_group_backend.base_group_backend"
) or super().has_group("base_group_backend.group_backend_ui_users")
if has_base_group_backend:
_logger.warning(
_logger.debug(
"Forcing has_group to return True"
+ " for group_backend and base_group_backend_ui_users"
+ " for base_group_backend and base_group_backend_ui_users"
)
return has_base_group_backend
return res
Expand Down
2 changes: 2 additions & 0 deletions base_group_backend/security/ir.model.access.csv
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,5 @@ backend_ui_users_res_partner_industry,backend_ui_users_res_partner_industry,base
backend_ui_users_res_users_identitycheck,backend_ui_users_res_users_identitycheck,base.model_res_users_identitycheck,group_backend_ui_users,1,1,1,0
backend_ui_users_res_bank,backend_ui_users_res_bank,base.model_res_bank,group_backend_ui_users,1,0,0,0
backend_ui_users_res_partner_bank,backend_ui_users_res_partner_bank,base.model_res_partner_bank,group_backend_ui_users,1,0,0,0
backend_ui_users_res_calendar_event,backend_ui_users_res_calendar_event,calendar.model_calendar_event,group_backend_ui_users,1,0,0,0
backend_ui_users_res_calendar_attendee,backend_ui_users_res_calendar_attendee,calendar.model_calendar_attendee,group_backend_ui_users,1,0,0,0
12 changes: 7 additions & 5 deletions base_group_backend/static/description/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
Expand All @@ -9,10 +8,11 @@

/*
:Author: David Goodger (goodger@python.org)
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Copyright: This stylesheet has been placed in the public domain.

Default cascading style sheet for the HTML output of Docutils.
Despite the name, some widely supported CSS2 features are used.

See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
Expand Down Expand Up @@ -275,7 +275,7 @@
margin-left: 2em ;
margin-right: 2em }

pre.code .ln { color: grey; } /* line numbers */
pre.code .ln { color: gray; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
Expand All @@ -301,7 +301,7 @@
span.pre {
white-space: pre }

span.problematic {
span.problematic, pre.problematic {
color: red }

span.section-subtitle {
Expand Down Expand Up @@ -487,7 +487,9 @@ <h1>Contributors</h1>
<div class="section" id="maintainers">
<h1>Maintainers</h1>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
Expand Down
11 changes: 11 additions & 0 deletions base_group_backend/tests/test_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def setUpClass(cls):
cls.portal_ui_user = cls.env.ref(
"base_group_backend.user_demo_external_with_ui"
)
cls.menu_app = cls.env.ref("base.menu_management")

def test_has_groups(self):
self.assertTrue(self.internal_user.has_group("base.group_user"))
Expand All @@ -29,3 +30,13 @@ def test_share(self):
)
self.assertFalse(self.portal_user.share)
self.assertFalse(self.portal_ui_user.share)

def test_no_roots_menu_with_no_groups(self):
self.assertNotIn(
self.menu_app,
self.env["ir.ui.menu"].with_user(self.portal_ui_user).get_user_roots(),
)
self.assertIn(
self.menu_app,
self.env["ir.ui.menu"].with_user(self.internal_user).get_user_roots(),
)
Loading