diff --git a/web_filter_groups/README.rst b/web_filter_groups/README.rst new file mode 100644 index 000000000..5822e1cae --- /dev/null +++ b/web_filter_groups/README.rst @@ -0,0 +1,64 @@ +================= +Web Filter Groups +================= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:daf4856fd71c931dc451d9da4c54e93eac42013ecdb5dac724d24818cbd453a5 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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-tegin%2Fcb--addons-lightgray.png?logo=github + :target: https://github.com/tegin/cb-addons/tree/16.0/web_filter_groups + :alt: tegin/cb-addons + +|badge1| |badge2| |badge3| + +Add a group that shows the filters. If you don't have it, no +personalized filters are showed. + +**Table of contents** + +.. contents:: + :local: + +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 +------- + +* Dixmit +* CreuBlanca + +Contributors +------------ + +- `Dixmit `__ + + - Enric Tobella + +Maintainers +----------- + +This module is part of the `tegin/cb-addons `_ project on GitHub. + +You are welcome to contribute. diff --git a/web_filter_groups/__init__.py b/web_filter_groups/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/web_filter_groups/__manifest__.py b/web_filter_groups/__manifest__.py new file mode 100644 index 000000000..3379c76c7 --- /dev/null +++ b/web_filter_groups/__manifest__.py @@ -0,0 +1,20 @@ +# Copyright 2025 Dixmit +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +{ + "name": "Web Filter Groups", + "summary": """Make Advanced filters hidden if you are not in a certain group""", + "version": "16.0.1.0.0", + "license": "AGPL-3", + "author": "Dixmit,CreuBlanca", + "website": "https://github.com/tegin/cb-addons", + "depends": ["web"], + "data": ["security/security.xml"], + "demo": [], + "assets": { + "web.assets_backend": [ + "web_filter_groups/static/src/**/*.esm.js", + "web_filter_groups/static/src/**/*.xml", + ] + }, +} diff --git a/web_filter_groups/pyproject.toml b/web_filter_groups/pyproject.toml new file mode 100644 index 000000000..4231d0ccc --- /dev/null +++ b/web_filter_groups/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/web_filter_groups/readme/CONTRIBUTORS.md b/web_filter_groups/readme/CONTRIBUTORS.md new file mode 100644 index 000000000..2c066ba7f --- /dev/null +++ b/web_filter_groups/readme/CONTRIBUTORS.md @@ -0,0 +1,2 @@ +- [Dixmit](https://www.dixmit.com) + - Enric Tobella diff --git a/web_filter_groups/readme/DESCRIPTION.md b/web_filter_groups/readme/DESCRIPTION.md new file mode 100644 index 000000000..36e492ae5 --- /dev/null +++ b/web_filter_groups/readme/DESCRIPTION.md @@ -0,0 +1 @@ +Add a group that shows the filters. If you don't have it, no personalized filters are showed. \ No newline at end of file diff --git a/web_filter_groups/security/security.xml b/web_filter_groups/security/security.xml new file mode 100644 index 000000000..38c95f826 --- /dev/null +++ b/web_filter_groups/security/security.xml @@ -0,0 +1,7 @@ + + + + Show Custom Filters and Group by + + + diff --git a/web_filter_groups/static/description/icon.png b/web_filter_groups/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/web_filter_groups/static/description/icon.png differ diff --git a/web_filter_groups/static/description/index.html b/web_filter_groups/static/description/index.html new file mode 100644 index 000000000..0f2f96bd1 --- /dev/null +++ b/web_filter_groups/static/description/index.html @@ -0,0 +1,421 @@ + + + + + +Web Filter Groups + + + +
+

Web Filter Groups

+ + +

Beta License: AGPL-3 tegin/cb-addons

+

Add a group that shows the filters. If you don’t have it, no +personalized filters are showed.

+

Table of contents

+ +
+

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

+
    +
  • Dixmit
  • +
  • CreuBlanca
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is part of the tegin/cb-addons project on GitHub.

+

You are welcome to contribute.

+
+
+
+ + diff --git a/web_filter_groups/static/src/components/filter_menu/filter_menu.esm.js b/web_filter_groups/static/src/components/filter_menu/filter_menu.esm.js new file mode 100644 index 000000000..63168f423 --- /dev/null +++ b/web_filter_groups/static/src/components/filter_menu/filter_menu.esm.js @@ -0,0 +1,18 @@ +/** @odoo-module **/ + +import {FilterMenu} from "@web/search/filter_menu/filter_menu"; +import {patch} from "@web/core/utils/patch"; +import {useService} from "@web/core/utils/hooks"; +import {onWillStart} from "@odoo/owl"; + +patch(FilterMenu.prototype, "web_filter_groups.FilterMenu", { + setup() { + this._super.apply(this, arguments); + this.user = useService("user"); + onWillStart(async () => { + this.showFilter = await this.user.hasGroup( + "web_filter_groups.filter_group" + ); + }); + }, +}); diff --git a/web_filter_groups/static/src/components/filter_menu/filter_menu.xml b/web_filter_groups/static/src/components/filter_menu/filter_menu.xml new file mode 100644 index 000000000..4e8614f01 --- /dev/null +++ b/web_filter_groups/static/src/components/filter_menu/filter_menu.xml @@ -0,0 +1,14 @@ + + + + + showFilter + + + showFilter + + + diff --git a/web_filter_groups/static/src/components/group_by_menu/group_by_menu.esm.js b/web_filter_groups/static/src/components/group_by_menu/group_by_menu.esm.js new file mode 100644 index 000000000..126d13d16 --- /dev/null +++ b/web_filter_groups/static/src/components/group_by_menu/group_by_menu.esm.js @@ -0,0 +1,21 @@ +/** @odoo-module **/ + +import {GroupByMenu} from "@web/search/group_by_menu/group_by_menu"; +import {patch} from "@web/core/utils/patch"; +import {useService} from "@web/core/utils/hooks"; +import {onWillStart} from "@odoo/owl"; + +patch(GroupByMenu.prototype, "web_filter_groups.GroupByMenu", { + setup() { + this._super.apply(this, arguments); + this.user = useService("user"); + onWillStart(async () => { + this.showFilter = await this.user.hasGroup( + "web_filter_groups.filter_group" + ); + }); + }, + get hideCustomGroupBy() { + return !this.showFilter || this._super.apply(this, arguments); + }, +});