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

TA#66764 [MIG][16.0] admin_light_filters #205

Merged
merged 3 commits into from
Oct 8, 2024
Merged
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
1 change: 1 addition & 0 deletions .docker_files/main/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
45 changes: 45 additions & 0 deletions admin_light_filters/README.rst
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions admin_light_filters/__init__.py
Original file line number Diff line number Diff line change
@@ -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).
19 changes: 19 additions & 0 deletions admin_light_filters/__manifest__.py
Original file line number Diff line number Diff line change
@@ -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).

{

Check warning on line 4 in admin_light_filters/__manifest__.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

admin_light_filters/__manifest__.py#L4

Statement seems to have no effect
'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,
}
47 changes: 47 additions & 0 deletions admin_light_filters/i18n/fr.po
Original file line number Diff line number Diff line change
@@ -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"
10 changes: 10 additions & 0 deletions admin_light_filters/security/admin_light_security.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>

<record id="group_custom_filters" model="res.groups">
<field name="name">Custom Filters</field>
<field name="category_id" ref="admin_light_base.module_category_admin"/>
<field name="implied_ids" eval="[(4, ref('admin_light_base.group_admin'))]"/>
</record>

</odoo>
25 changes: 25 additions & 0 deletions admin_light_filters/security/ir_filters_security.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<function name="write" model="ir.model.data">
<function name="search" model="ir.model.data">
<value
eval="[('module', '=', 'filter_multi_user'), ('name', '=', 'ir_filters_employee_rule')]"
/>
</function>
<value eval="{'noupdate': False}" />
</function>

<record id="filter_multi_user.ir_filters_employee_rule" model="ir.rule">
<field name="perm_unlink" eval="True"/>
</record>

<function name="write" model="ir.model.data">
<function name="search" model="ir.model.data">
<value
eval="[('module', '=', 'filter_multi_user'), ('name', '=', 'ir_filters_employee_rule')]"
/>
</function>
<value eval="{'noupdate': True}" />
</function>

</odoo>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added admin_light_filters/static/description/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions admin_light_filters/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -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
42 changes: 42 additions & 0 deletions admin_light_filters/tests/test_filter.py
Original file line number Diff line number Diff line change
@@ -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": "%[email protected]" % 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()
8 changes: 8 additions & 0 deletions admin_light_filters/views/ir_filters_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<menuitem parent="admin_light_web.menu_web" name="User-defined Filters"
id="menu_user_ir_filters" action="base.actions_ir_filters_view" sequence="7"
groups="admin_light_filters.group_custom_filters"/>
</data>
</odoo>
Loading