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

[18.0][MIG] base_menu_visibility_restriction: Migration to 18.0 #955

Open
wants to merge 25 commits into
base: 18.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
28f14d5
[ADD] base_menu_visibility_restriction: Restrict (with groups) menu v…
victoralmau Nov 11, 2020
3de48b2
[UPD] Update base_menu_visibility_restriction.pot
oca-travis Dec 28, 2020
5b3982f
[UPD] README.rst
OCA-git-bot Dec 28, 2020
e2208c7
[14.0][MIG] base_menu_visibility_restriction
aphon61bank Jan 25, 2021
424cfba
[UPD] Update base_menu_visibility_restriction.pot
oca-travis Apr 6, 2021
bb4ff56
[UPD] README.rst
OCA-git-bot Apr 6, 2021
2a4b9d7
[IMP] : black, isort, prettier
JasminSForgeFlow Dec 10, 2021
664c7f4
[15.0][MIG] base_menu_visibility_restriction: Migration to 15.0
JasminSForgeFlow Dec 10, 2021
dc9ae57
[UPD] Update base_menu_visibility_restriction.pot
Dec 10, 2021
861c5bf
[UPD] README.rst
OCA-git-bot Dec 10, 2021
05a7767
[IMP] base_menu_visibility_restriction: pre-commit stuff
dsolanki-initos Mar 20, 2023
d6d9949
[MIG] base_menu_visibility_restriction: Migration to 16.0
dsolanki-initos Mar 20, 2023
5870d2a
[UPD] Update base_menu_visibility_restriction.pot
Jun 22, 2023
6aeccb9
[UPD] README.rst
OCA-git-bot Jun 22, 2023
06d08dd
Added translation using Weblate (Spanish)
kikopeiro Aug 28, 2023
c40e2e6
[UPD] README.rst
OCA-git-bot Sep 3, 2023
a7560f7
Translated using Weblate (Spanish)
kikopeiro Aug 28, 2023
1ec126b
Added translation using Weblate (Italian)
mymage Dec 29, 2023
c13b187
Translated using Weblate (Italian)
mymage Dec 31, 2023
510fd95
[IMP] base_menu_visibility_restriction: pre-commit auto fixes
May 9, 2024
eee47ea
[MIG] base_menu_visibility_restriction: Migration to 17.0
May 9, 2024
8646da3
[UPD] Update base_menu_visibility_restriction.pot
Sep 16, 2024
d9bbe8e
[BOT] post-merge updates
OCA-git-bot Sep 16, 2024
c4e71e9
Update translation files
weblate Sep 16, 2024
ec732c8
[MIG] base_menu_visibility_restriction: Migration to 18.0
gustitammam Oct 15, 2024
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
104 changes: 104 additions & 0 deletions base_menu_visibility_restriction/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
================================
Base Menu Visibility Restriction
================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:eb9f5f2eca3b8520ba152aac34d978b776132af5ecd2770ddb3eb6e99190070c
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png
:target: https://odoo-community.org/page/development-status
:alt: Production/Stable
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--ux-lightgray.png?logo=github
:target: https://github.com/OCA/server-ux/tree/17.0/base_menu_visibility_restriction
:alt: OCA/server-ux
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/server-ux-17-0/server-ux-17-0-base_menu_visibility_restriction
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/server-ux&target_branch=17.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This addon lets you assign "excluded groups" to menu items. If a user
belongs to a group that is assigned to a menu item as an excluded group,
the user will not be able to see the menu item.

**Table of contents**

.. contents::
:local:

Usage
=====

To use this module, you need to:

1. Activate the developer mode
2. Go to *Settings > Technical > User interface > Menu Items*.
3. Search for any menu and edit it.
4. Update "Excluded groups" with one group.
5. Login with a user of that group, and you won't see such menu.

You can try with demo data for the menu Apps > App Store and user demo.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/server-ux/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/server-ux/issues/new?body=module:%20base_menu_visibility_restriction%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
-------

* Tecnativa

Contributors
------------

- `Tecnativa <https://www.tecnativa.com>`__:

- Víctor Martínez

- Dhara Solanki <[email protected]>
- Nedas Žilinskas <[email protected]>

Maintainers
-----------

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

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.

.. |maintainer-victoralmau| image:: https://github.com/victoralmau.png?size=40px
:target: https://github.com/victoralmau
:alt: victoralmau

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-victoralmau|

This module is part of the `OCA/server-ux <https://github.com/OCA/server-ux/tree/17.0/base_menu_visibility_restriction>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions base_menu_visibility_restriction/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
17 changes: 17 additions & 0 deletions base_menu_visibility_restriction/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2020 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

{
"name": "Base Menu Visibility Restriction",
"version": "18.0.1.0.0",
"category": "Extra Tools",
"development_status": "Production/Stable",
"author": "Tecnativa, Odoo Community Association (OCA)",
"summary": "Restrict (with groups) menu visibilty",
"website": "https://github.com/OCA/server-ux",
"license": "AGPL-3",
"depends": ["web_tour"],
"maintainers": ["victoralmau"],
"data": ["views/ir_ui_menu.xml"],
"installable": True,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * base_menu_visibility_restriction
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 17.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: base_menu_visibility_restriction
#: model:ir.model.fields,field_description:base_menu_visibility_restriction.field_ir_ui_menu__excluded_group_ids
msgid "Excluded Groups"
msgstr ""

#. module: base_menu_visibility_restriction
#: model:ir.model,name:base_menu_visibility_restriction.model_ir_ui_menu
msgid "Menu"
msgstr ""
30 changes: 30 additions & 0 deletions base_menu_visibility_restriction/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * base_menu_visibility_restriction
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2023-09-03 13:43+0000\n"
"Last-Translator: kikopeiro <[email protected]>\n"
"Language-Team: none\n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.17\n"

#. module: base_menu_visibility_restriction
#: model:ir.model.fields,field_description:base_menu_visibility_restriction.field_ir_ui_menu__excluded_group_ids
msgid "Excluded Groups"
msgstr "Grupos excluidos"

#. module: base_menu_visibility_restriction
#: model:ir.model,name:base_menu_visibility_restriction.model_ir_ui_menu
msgid "Menu"
msgstr "Menú"

#~ msgid "Menu visibility restriction demo group"
#~ msgstr "Grupo demo de restricción de visibilidad de menús"
30 changes: 30 additions & 0 deletions base_menu_visibility_restriction/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * base_menu_visibility_restriction
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2023-12-31 17:24+0000\n"
"Last-Translator: mymage <[email protected]>\n"
"Language-Team: none\n"
"Language: it\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.17\n"

#. module: base_menu_visibility_restriction
#: model:ir.model.fields,field_description:base_menu_visibility_restriction.field_ir_ui_menu__excluded_group_ids
msgid "Excluded Groups"
msgstr "Gruppi esclusi"

#. module: base_menu_visibility_restriction
#: model:ir.model,name:base_menu_visibility_restriction.model_ir_ui_menu
msgid "Menu"
msgstr "Menu"

#~ msgid "Menu visibility restriction demo group"
#~ msgstr "Gruppo demo restrizione visibilità menu"
1 change: 1 addition & 0 deletions base_menu_visibility_restriction/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import ir_ui_menu
26 changes: 26 additions & 0 deletions base_menu_visibility_restriction/models/ir_ui_menu.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright 2020 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import api, fields, models, tools


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

excluded_group_ids = fields.Many2many(
comodel_name="res.groups",
relation="ir_ui_menu_excluded_group_rel",
column1="menu_id",
column2="gid",
string="Excluded Groups",
)

@api.model
@tools.ormcache("frozenset(self.env.user.groups_id.ids)", "debug")
def _visible_menu_ids(self, debug=False):
"""Return the ids of the menu items visible to the user."""
visible = super()._visible_menu_ids(debug=debug)
context = {"ir.ui.menu.full_list": True}
menus = self.with_context(**context).browse(visible)
groups = self.env.user.groups_id
visible = menus - menus.filtered(lambda menu: menu.excluded_group_ids & groups)
return set(visible.ids)
3 changes: 3 additions & 0 deletions base_menu_visibility_restriction/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
4 changes: 4 additions & 0 deletions base_menu_visibility_restriction/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- [Tecnativa](https://www.tecnativa.com):
- Víctor Martínez
- Dhara Solanki \<<[email protected]>\>
- Nedas Žilinskas \<<[email protected]>\>
3 changes: 3 additions & 0 deletions base_menu_visibility_restriction/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This addon lets you assign "excluded groups" to menu items. If a user
belongs to a group that is assigned to a menu item as an excluded group,
the user will not be able to see the menu item.
9 changes: 9 additions & 0 deletions base_menu_visibility_restriction/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
To use this module, you need to:

1. Activate the developer mode
2. Go to *Settings \> Technical \> User interface \> Menu Items*.
3. Search for any menu and edit it.
4. Update "Excluded groups" with one group.
5. Login with a user of that group, and you won't see such menu.

You can try with demo data for the menu Apps \> App Store and user demo.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading