diff --git a/dms_user_role/README.rst b/dms_user_role/README.rst new file mode 100644 index 000000000..86edfa162 --- /dev/null +++ b/dms_user_role/README.rst @@ -0,0 +1,97 @@ +============= +DMS User Role +============= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:35aa1f1c4b7cc8c6de3e9f920b4c825356bfae6c0c9a675a5ab84cdaaec039eb + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |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%2Fdms-lightgray.png?logo=github + :target: https://github.com/OCA/dms/tree/18.0/dms_user_role + :alt: OCA/dms +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/dms-18-0/dms-18-0-dms_user_role + :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/dms&target_branch=18.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Use of roles (module base_user_role) in DMS access groups. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +1. Go to Settings / Users & Companies / Roles and create a new one. +2. Go to Documents / Configuration / Access groups and create or edit + one. +3. Set in the "Roles" tab the one we have just created. +4. Go back to the role, edit it and add an extra user. +5. The extra user will have been added in the "Users" tab. + +Bug Tracker +=========== + +Bugs are tracked on `GitHub 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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* Tecnativa + +Contributors +------------ + +- `Tecnativa `__: + + - Víctor Martínez + - Pedro M. Baeza + +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 `__: + +|maintainer-victoralmau| + +This module is part of the `OCA/dms `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/dms_user_role/__init__.py b/dms_user_role/__init__.py new file mode 100644 index 000000000..4b76c7b2d --- /dev/null +++ b/dms_user_role/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from . import models diff --git a/dms_user_role/__manifest__.py b/dms_user_role/__manifest__.py new file mode 100644 index 000000000..b20d55ad3 --- /dev/null +++ b/dms_user_role/__manifest__.py @@ -0,0 +1,16 @@ +# Copyright 2024 Tecnativa - Víctor Martínez +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + "name": "DMS User Role", + "version": "19.0.1.0.0", + "category": "Document Management", + "website": "https://github.com/OCA/dms", + "author": "Tecnativa, Odoo Community Association (OCA)", + "license": "AGPL-3", + "depends": ["dms", "base_user_role"], + "installable": True, + "data": [ + "views/dms_access_group_views.xml", + ], + "maintainers": ["victoralmau"], +} diff --git a/dms_user_role/i18n/ar.po b/dms_user_role/i18n/ar.po new file mode 100644 index 000000000..53b06195e --- /dev/null +++ b/dms_user_role/i18n/ar.po @@ -0,0 +1,27 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * dms_user_role +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: Automatically generated\n" +"Language-Team: none\n" +"Language: ar\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=6; plural=n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : n%100>=3 " +"&& n%100<=10 ? 3 : n%100>=11 ? 4 : 5;\n" + +#. module: dms_user_role +#: model:ir.model,name:dms_user_role.model_dms_access_group +msgid "Record Access Groups" +msgstr "" + +#. module: dms_user_role +#: model:ir.model.fields,field_description:dms_user_role.field_dms_access_group__role_ids +#: model_terms:ir.ui.view,arch_db:dms_user_role.view_dms_access_groups_form +msgid "Roles" +msgstr "" diff --git a/dms_user_role/i18n/dms_user_role.pot b/dms_user_role/i18n/dms_user_role.pot new file mode 100644 index 000000000..1ea0df0f4 --- /dev/null +++ b/dms_user_role/i18n/dms_user_role.pot @@ -0,0 +1,25 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * dms_user_role +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.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: dms_user_role +#: model:ir.model,name:dms_user_role.model_dms_access_group +msgid "Record Access Groups" +msgstr "" + +#. module: dms_user_role +#: model:ir.model.fields,field_description:dms_user_role.field_dms_access_group__role_ids +#: model_terms:ir.ui.view,arch_db:dms_user_role.view_dms_access_groups_form +msgid "Roles" +msgstr "" diff --git a/dms_user_role/i18n/es.po b/dms_user_role/i18n/es.po new file mode 100644 index 000000000..feb609f5f --- /dev/null +++ b/dms_user_role/i18n/es.po @@ -0,0 +1,29 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * dms_user_role +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-03-05 10:23+0000\n" +"PO-Revision-Date: 2024-10-08 17:06+0000\n" +"Last-Translator: Víctor Martínez \n" +"Language-Team: \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 5.6.2\n" + +#. module: dms_user_role +#: model:ir.model,name:dms_user_role.model_dms_access_group +msgid "Record Access Groups" +msgstr "Grupos de acceso de registro" + +#. module: dms_user_role +#: model:ir.model.fields,field_description:dms_user_role.field_dms_access_group__role_ids +#: model_terms:ir.ui.view,arch_db:dms_user_role.view_dms_access_groups_form +msgid "Roles" +msgstr "Roles" diff --git a/dms_user_role/i18n/it.po b/dms_user_role/i18n/it.po new file mode 100644 index 000000000..48e9074c4 --- /dev/null +++ b/dms_user_role/i18n/it.po @@ -0,0 +1,28 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * dms_user_role +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2024-04-04 16:35+0000\n" +"Last-Translator: mymage \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: dms_user_role +#: model:ir.model,name:dms_user_role.model_dms_access_group +msgid "Record Access Groups" +msgstr "Gruppi di accesso al record" + +#. module: dms_user_role +#: model:ir.model.fields,field_description:dms_user_role.field_dms_access_group__role_ids +#: model_terms:ir.ui.view,arch_db:dms_user_role.view_dms_access_groups_form +msgid "Roles" +msgstr "Ruoli" diff --git a/dms_user_role/i18n/sl.po b/dms_user_role/i18n/sl.po new file mode 100644 index 000000000..361e739f3 --- /dev/null +++ b/dms_user_role/i18n/sl.po @@ -0,0 +1,29 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * dms_user_role +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2026-06-09 11:46+0000\n" +"Last-Translator: Matjaz Mozetic \n" +"Language-Team: none\n" +"Language: sl\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=4; plural=n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || " +"n%100==4 ? 2 : 3;\n" +"X-Generator: Weblate 5.15.2\n" + +#. module: dms_user_role +#: model:ir.model,name:dms_user_role.model_dms_access_group +msgid "Record Access Groups" +msgstr "Skupine dostopa do zapisov" + +#. module: dms_user_role +#: model:ir.model.fields,field_description:dms_user_role.field_dms_access_group__role_ids +#: model_terms:ir.ui.view,arch_db:dms_user_role.view_dms_access_groups_form +msgid "Roles" +msgstr "Vloge" diff --git a/dms_user_role/i18n/sv.po b/dms_user_role/i18n/sv.po new file mode 100644 index 000000000..9ed50432d --- /dev/null +++ b/dms_user_role/i18n/sv.po @@ -0,0 +1,28 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * dms_user_role +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2025-09-19 13:31+0000\n" +"Last-Translator: jakobkrabbe \n" +"Language-Team: none\n" +"Language: sv\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 5.10.4\n" + +#. module: dms_user_role +#: model:ir.model,name:dms_user_role.model_dms_access_group +msgid "Record Access Groups" +msgstr "Grupper för åtkomst till register" + +#. module: dms_user_role +#: model:ir.model.fields,field_description:dms_user_role.field_dms_access_group__role_ids +#: model_terms:ir.ui.view,arch_db:dms_user_role.view_dms_access_groups_form +msgid "Roles" +msgstr "Roller" diff --git a/dms_user_role/models/__init__.py b/dms_user_role/models/__init__.py new file mode 100644 index 000000000..227172e52 --- /dev/null +++ b/dms_user_role/models/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import dms_access_group diff --git a/dms_user_role/models/dms_access_group.py b/dms_user_role/models/dms_access_group.py new file mode 100644 index 000000000..9c0e2e757 --- /dev/null +++ b/dms_user_role/models/dms_access_group.py @@ -0,0 +1,26 @@ +# Copyright 2024 Tecnativa - Víctor Martínez +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import api, fields, models + + +class DmsAccessGroup(models.Model): + _inherit = "dms.access.group" + + role_ids = fields.Many2many( + comodel_name="res.users.role", + relation="dms_access_group_user_roles_rel", + column1="gid", + column2="rid", + string="Roles", + ) + + @api.depends("role_ids", "role_ids.users") + def _compute_users(self): + """Add the corresponding depends and the users of the roles.""" + res = super()._compute_users() + for record in self.filtered("role_ids"): + users = record.users + users |= record.mapped("role_ids.users") + record.update({"users": users, "count_users": len(users)}) + return res diff --git a/dms_user_role/pyproject.toml b/dms_user_role/pyproject.toml new file mode 100644 index 000000000..4231d0ccc --- /dev/null +++ b/dms_user_role/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/dms_user_role/readme/CONTRIBUTORS.md b/dms_user_role/readme/CONTRIBUTORS.md new file mode 100644 index 000000000..5fee39042 --- /dev/null +++ b/dms_user_role/readme/CONTRIBUTORS.md @@ -0,0 +1,3 @@ +- [Tecnativa](https://www.tecnativa.com): + - Víctor Martínez + - Pedro M. Baeza diff --git a/dms_user_role/readme/DESCRIPTION.md b/dms_user_role/readme/DESCRIPTION.md new file mode 100644 index 000000000..737c57ebf --- /dev/null +++ b/dms_user_role/readme/DESCRIPTION.md @@ -0,0 +1 @@ +Use of roles (module base_user_role) in DMS access groups. diff --git a/dms_user_role/readme/USAGE.md b/dms_user_role/readme/USAGE.md new file mode 100644 index 000000000..b818e0024 --- /dev/null +++ b/dms_user_role/readme/USAGE.md @@ -0,0 +1,6 @@ +1. Go to Settings / Users & Companies / Roles and create a new one. +2. Go to Documents / Configuration / Access groups and create or edit + one. +3. Set in the "Roles" tab the one we have just created. +4. Go back to the role, edit it and add an extra user. +5. The extra user will have been added in the "Users" tab. diff --git a/dms_user_role/static/description/icon.png b/dms_user_role/static/description/icon.png new file mode 100644 index 000000000..a561495f1 Binary files /dev/null and b/dms_user_role/static/description/icon.png differ diff --git a/dms_user_role/static/description/index.html b/dms_user_role/static/description/index.html new file mode 100644 index 000000000..90b5422ec --- /dev/null +++ b/dms_user_role/static/description/index.html @@ -0,0 +1,441 @@ + + + + + +DMS User Role + + + +
+

DMS User Role

+ + +

Beta License: AGPL-3 OCA/dms Translate me on Weblate Try me on Runboat

+

Use of roles (module base_user_role) in DMS access groups.

+

Table of contents

+ +
+

Usage

+
    +
  1. Go to Settings / Users & Companies / Roles and create a new one.
  2. +
  3. Go to Documents / Configuration / Access groups and create or edit +one.
  4. +
  5. Set in the “Roles” tab the one we have just created.
  6. +
  7. Go back to the role, edit it and add an extra user.
  8. +
  9. The extra user will have been added in the “Users” tab.
  10. +
+
+
+

Bug Tracker

+

Bugs are tracked on GitHub 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.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Tecnativa
  • +
+
+
+

Contributors

+
    +
  • Tecnativa:
      +
    • Víctor Martínez
    • +
    • Pedro M. Baeza
    • +
    +
  • +
+
+
+

Maintainers

+

This module is maintained by the OCA.

+ +Odoo Community Association + +

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.

+

Current maintainer:

+

victoralmau

+

This module is part of the OCA/dms project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/dms_user_role/tests/__init__.py b/dms_user_role/tests/__init__.py new file mode 100644 index 000000000..f512007a5 --- /dev/null +++ b/dms_user_role/tests/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) + +from . import test_dms_user_role diff --git a/dms_user_role/tests/test_dms_user_role.py b/dms_user_role/tests/test_dms_user_role.py new file mode 100644 index 000000000..cd7222b3a --- /dev/null +++ b/dms_user_role/tests/test_dms_user_role.py @@ -0,0 +1,52 @@ +# Copyright 2024-2025 Tecnativa - Víctor Martínez +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from odoo import Command +from odoo.tests import new_test_user +from odoo.tools import mute_logger + +from odoo.addons.base.tests.common import BaseCommon + + +class TestDmsUserRole(BaseCommon): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.user_a = new_test_user(cls.env, login="test_user_a") + cls.user_b = new_test_user(cls.env, login="test_user_b") + cls.user_c = new_test_user(cls.env, login="test_user_c") + cls.access_group = cls.env["dms.access.group"].create( + {"name": "Test group", "explicit_user_ids": [Command.link(cls.user_a.id)]} + ) + cls.user_role = cls.env["res.users.role"].create({"name": "Test user role"}) + + @mute_logger("odoo.models.unlink") + def test_user_role_change(self): + self.assertIn(self.user_a, self.access_group.users) + self.assertNotIn(self.user_b, self.access_group.users) + self.assertNotIn(self.user_c, self.access_group.users) + # Add User a to user_role: Without changes + self.user_role.line_ids = [Command.create({"user_id": self.user_a.id})] + self.assertIn(self.user_a, self.access_group.users) + self.assertNotIn(self.user_b, self.access_group.users) + self.assertNotIn(self.user_c, self.access_group.users) + # Set role to access group: Without changes + self.access_group.role_ids = [Command.link(self.user_role.id)] + self.assertIn(self.user_a, self.access_group.users) + self.assertNotIn(self.user_b, self.access_group.users) + self.assertNotIn(self.user_c, self.access_group.users) + # Add User b to user_role: User b is added to access groups + self.user_role.line_ids = [Command.create({"user_id": self.user_b.id})] + self.assertIn(self.user_a, self.access_group.users) + self.assertIn(self.user_b, self.access_group.users) + self.assertNotIn(self.user_c, self.access_group.users) + # Add User c to user_role: User c is added to access groups + self.user_role.line_ids = [Command.create({"user_id": self.user_c.id})] + self.assertIn(self.user_a, self.access_group.users) + self.assertIn(self.user_b, self.access_group.users) + self.assertIn(self.user_c, self.access_group.users) + # Remove User c from user role: User c is removed from access group + line_b = self.user_role.line_ids.filtered(lambda x: x.user_id == self.user_b) + self.user_role.line_ids = [Command.delete(line_b.id)] + self.assertIn(self.user_a, self.access_group.users) + self.assertNotIn(self.user_b, self.access_group.users) + self.assertIn(self.user_c, self.access_group.users) diff --git a/dms_user_role/views/dms_access_group_views.xml b/dms_user_role/views/dms_access_group_views.xml new file mode 100644 index 000000000..10c233207 --- /dev/null +++ b/dms_user_role/views/dms_access_group_views.xml @@ -0,0 +1,20 @@ + + + + dms_access.group.form + dms.access.group + + + + + + + + + + + + + + +