diff --git a/.docker_files/main/__manifest__.py b/.docker_files/main/__manifest__.py index 4b3b3dd6..fa98f195 100644 --- a/.docker_files/main/__manifest__.py +++ b/.docker_files/main/__manifest__.py @@ -24,6 +24,7 @@ "admin_light_mail_gmail", "admin_light_mail_outlook", "admin_light_web", + "admin_light_filters", "attachment_minio", "lang_fr_activated", "mail_notification_no_action_button", diff --git a/Dockerfile b/Dockerfile index 5f7009b6..aeb723d6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,6 +24,7 @@ COPY admin_light_mail /mnt/extra-addons/admin_light_mail COPY admin_light_mail_gmail /mnt/extra-addons/admin_light_mail_gmail COPY admin_light_mail_outlook /mnt/extra-addons/admin_light_mail_outlook COPY admin_light_web /mnt/extra-addons/admin_light_web +COPY admin_light_filters /mnt/extra-addons/admin_light_filters COPY attachment_minio /mnt/extra-addons/attachment_minio COPY lang_fr_activated /mnt/extra-addons/lang_fr_activated COPY mail_notification_no_action_button /mnt/extra-addons/mail_notification_no_action_button diff --git a/admin_light_filters/README.rst b/admin_light_filters/README.rst new file mode 100644 index 00000000..987ce778 --- /dev/null +++ b/admin_light_filters/README.rst @@ -0,0 +1,45 @@ +===================== +Admin Light Filters +===================== + +This module introduces user-defined filter management within the Admin Light application. + +**Table of contents** + +.. contents:: + :local: + +Overview +======== + +The `Admin Light Filters` module adds functionality for managing filters by users in the Admin Light interface. It introduces a new group that allows non-admin users to manage custom filters under certain conditions. + +User Filter Management +======================= + +A new group, **Safe Administration / Custom Filters**, is added. Members of this group who are normal users (i.e., not the default admin) can manage filters according to specific rules. + +As a member of this group, under the menu **Administration > User Interface > User-defined Filters**, you can: + +- **Delete** filters where: + - The **Owner** field is empty. + - The **Owner** field contains your user. + +- **Modify** filters where: + - The **Owner** field is empty. + - The **Owner** field contains your user. + +- **Access** the **Groups** and **Users** fields to share filters with specific users or groups. + +.. image:: static/description/custom_filters_management.png + :alt: Custom filters management interface + +Contributors +============ + +* Numigi (tm) and all its contributors (https://bit.ly/numigiens) + +More information +================ + +* Meet us at https://bit.ly/numigi-com diff --git a/admin_light_filters/__init__.py b/admin_light_filters/__init__.py new file mode 100644 index 00000000..93948007 --- /dev/null +++ b/admin_light_filters/__init__.py @@ -0,0 +1,2 @@ +# Copyright 2024 Numigi (tm) and all its contributors (https://bit.ly/numigiens) +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). diff --git a/admin_light_filters/__manifest__.py b/admin_light_filters/__manifest__.py new file mode 100644 index 00000000..8cfadf59 --- /dev/null +++ b/admin_light_filters/__manifest__.py @@ -0,0 +1,19 @@ +# Copyright 2024 Numigi (tm) and all its contributors (https://bit.ly/numigiens) +# License AGPL-3 or later (http://www.gnu.org/licenses/lgpl). + +{ + 'name': 'Admin Light Filters', + 'version': "16.0.1.0.0", + 'author': 'Numigi', + 'maintainer': 'Numigi', + 'license': 'AGPL-3', + 'category': 'Other', + 'summary': 'Add user-defined filter management to the Admin Light user', + 'depends': ['admin_light_web', 'filter_multi_user'], + 'data': [ + 'security/admin_light_security.xml', + 'security/ir_filters_security.xml', + 'views/ir_filters_views.xml', + ], + 'installable': True, +} diff --git a/admin_light_filters/i18n/fr.po b/admin_light_filters/i18n/fr.po new file mode 100644 index 00000000..69c2c0f7 --- /dev/null +++ b/admin_light_filters/i18n/fr.po @@ -0,0 +1,47 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * admin_light_filters +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-10-03 06:28+0000\n" +"PO-Revision-Date: 2024-10-03 06:28+0000\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: admin_light_filters +#: model:res.groups,name:admin_light_filters.group_custom_filters +msgid "Custom Filters" +msgstr "Filtres personnalisés" + +#. module: admin_light_filters +#: model:ir.ui.menu,name:admin_light_filters.menu_user_ir_filters +msgid "User-defined Filters" +msgstr "Filtres utilisateurs" + +#. module: filter_multi_user +#: model:ir.model.fields,field_description:filter_multi_user.field_ir_filters__group_ids +msgid "Available for Groups" +msgstr "Disponible pour Groupes" + + +#. module: filter_multi_user +#: model:ir.model,name:filter_multi_user.model_ir_filters +msgid "Filters" +msgstr "Filtres" + +#. module: filter_multi_user +#: model_terms:ir.ui.view,arch_db:filter_multi_user.ir_filters_view_form +msgid "Owner" +msgstr "Propriétaire" + +#. module: filter_multi_user +#: model:ir.model.fields,field_description:filter_multi_user.field_ir_filters__user_ids +msgid "Users" +msgstr "Utilisateurs" diff --git a/admin_light_filters/security/admin_light_security.xml b/admin_light_filters/security/admin_light_security.xml new file mode 100644 index 00000000..e410718a --- /dev/null +++ b/admin_light_filters/security/admin_light_security.xml @@ -0,0 +1,10 @@ + + + + + Custom Filters + + + + + diff --git a/admin_light_filters/security/ir_filters_security.xml b/admin_light_filters/security/ir_filters_security.xml new file mode 100644 index 00000000..13176c28 --- /dev/null +++ b/admin_light_filters/security/ir_filters_security.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/admin_light_filters/static/description/custom_filters_management.png b/admin_light_filters/static/description/custom_filters_management.png new file mode 100644 index 00000000..24fb4f03 Binary files /dev/null and b/admin_light_filters/static/description/custom_filters_management.png differ diff --git a/admin_light_filters/static/description/icon.png b/admin_light_filters/static/description/icon.png new file mode 100644 index 00000000..92a86b10 Binary files /dev/null and b/admin_light_filters/static/description/icon.png differ diff --git a/admin_light_filters/tests/__init__.py b/admin_light_filters/tests/__init__.py new file mode 100644 index 00000000..f048b3ff --- /dev/null +++ b/admin_light_filters/tests/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2024 Numigi (tm) and all its contributors (https://bit.ly/numigiens) +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). + +from . import test_filter diff --git a/admin_light_filters/tests/test_filter.py b/admin_light_filters/tests/test_filter.py new file mode 100644 index 00000000..e3174794 --- /dev/null +++ b/admin_light_filters/tests/test_filter.py @@ -0,0 +1,42 @@ +# Copyright 2024 Numigi (tm) and all its contributors (https://bit.ly/numigiens) +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). + +from odoo.tests.common import TransactionCase + + +class TestPermission(TransactionCase): + + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.group_user = cls.env.ref("base.group_user") + cls.group_admin_filter = cls.env.ref("admin_light_filters.group_custom_filters") + cls.user_1 = cls._create_user( + "user_1", [cls.group_user, cls.group_admin_filter] + ) + cls.user_2 = cls._create_user("user_2", [cls.group_user]) + + @classmethod + def _create_user(cls, login, groups): + group_ids = [group.id for group in groups] + user = cls.env["res.users"].create( + { + "name": "Test User", + "login": login, + "password": "Demo_12345", + "email": "%s@yourcompany.com" % login, + "groups_id": [(6, 0, group_ids)], + } + ) + return user + + def test_05_delete_filter(self): + test_filter = self.env["ir.filters"].create( + { + "name": "Test filter", + "model_id": "ir.filters", + "user_id": False, + "manual_user_ids": [(6, 0, (self.user_1 + self.user_2).ids)], + } + ) + test_filter.with_user(self.user_1).unlink() diff --git a/admin_light_filters/views/ir_filters_views.xml b/admin_light_filters/views/ir_filters_views.xml new file mode 100644 index 00000000..7db85a92 --- /dev/null +++ b/admin_light_filters/views/ir_filters_views.xml @@ -0,0 +1,8 @@ + + + + + + \ No newline at end of file