Skip to content

Commit 2632ae1

Browse files
[ADD] web_custom_filter_groupby_visibility_control
1 parent f81f01e commit 2632ae1

File tree

20 files changed

+827
-0
lines changed

20 files changed

+827
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../../web_custom_filter_groupby_visibility_control
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import setuptools
2+
3+
setuptools.setup(
4+
setup_requires=['setuptools-odoo'],
5+
odoo_addon=True,
6+
)
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
============================================
2+
Web Custom Filter GroupBy Visibility Control
3+
============================================
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:e6b42245e8f445172fd95488fce48ce16240881b5e53d4730208a3b9db9e8197
11+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12+
13+
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
14+
:target: https://odoo-community.org/page/development-status
15+
:alt: Beta
16+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
17+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
18+
:alt: License: AGPL-3
19+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--ux-lightgray.png?logo=github
20+
:target: https://github.com/OCA/server-ux/tree/15.0/web_custom_filter_groupby_visibility_control
21+
:alt: OCA/server-ux
22+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23+
:target: https://translation.odoo-community.org/projects/server-ux-15-0/server-ux-15-0-web_custom_filter_groupby_visibility_control
24+
:alt: Translate me on Weblate
25+
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/server-ux&target_branch=15.0
27+
:alt: Try me on Runboat
28+
29+
|badge1| |badge2| |badge3| |badge4| |badge5|
30+
31+
This module allows controlling the visibility of the “Add Custom Filter”
32+
and “Add Custom Group” options in the search view for specific models.
33+
34+
**Table of contents**
35+
36+
.. contents::
37+
:local:
38+
39+
Configuration
40+
=============
41+
42+
To Hide “Add Custom Filter” and “Add Custom Group” Options
43+
44+
1. Go to **Settings → Technical → Database Structure → Models**.
45+
2. Open the model where you want to restrict the **“Add Custom Filter”**
46+
and
47+
**“Add Custom Group”** options.
48+
3. Set the **"Hide Custom Filter/Group By for Groups"** and/or
49+
**"Hide Custom Filter/Group By for Users"** fields as needed. If no
50+
users or groups are assigned, Odoo will follow its standard behavior,
51+
and the
52+
options will remain visible.
53+
54+
Models can also be assigned from the Groups or Users form view by adding
55+
them under the "Hidden Custom Filter/Group By Models" tab.
56+
57+
Bug Tracker
58+
===========
59+
60+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/server-ux/issues>`_.
61+
In case of trouble, please check there if your issue has already been reported.
62+
If you spotted it first, help us to smash it by providing a detailed and welcomed
63+
`feedback <https://github.com/OCA/server-ux/issues/new?body=module:%20web_custom_filter_groupby_visibility_control%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
64+
65+
Do not contact contributors directly about support or help with technical issues.
66+
67+
Credits
68+
=======
69+
70+
Authors
71+
-------
72+
73+
* Quartile
74+
75+
Contributors
76+
------------
77+
78+
- `Quartile <https://www.quartile.co>`__:
79+
80+
- Aung Ko Ko Lin
81+
82+
Maintainers
83+
-----------
84+
85+
This module is maintained by the OCA.
86+
87+
.. image:: https://odoo-community.org/logo.png
88+
:alt: Odoo Community Association
89+
:target: https://odoo-community.org
90+
91+
OCA, or the Odoo Community Association, is a nonprofit organization whose
92+
mission is to support the collaborative development of Odoo features and
93+
promote its widespread use.
94+
95+
This module is part of the `OCA/server-ux <https://github.com/OCA/server-ux/tree/15.0/web_custom_filter_groupby_visibility_control>`_ project on GitHub.
96+
97+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import models
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Copyright 2025 Quartile (https://www.quartile.co)
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
{
4+
"name": "Web Custom Filter GroupBy Visibility Control",
5+
"category": "Tools",
6+
"version": "15.0.1.0.0",
7+
"author": "Quartile, Odoo Community Association (OCA)",
8+
"website": "https://github.com/OCA/server-ux",
9+
"license": "AGPL-3",
10+
"depends": ["web"],
11+
"data": [
12+
"views/ir_model_views.xml",
13+
"views/res_groups_views.xml",
14+
"views/res_users_views.xml",
15+
],
16+
"assets": {
17+
"web.assets_qweb": [
18+
"web_custom_filter_groupby_visibility_control/static/src/xml/*.xml",
19+
],
20+
"web.assets_backend": [
21+
"web_custom_filter_groupby_visibility_control/static/src/js/*.esm.js",
22+
],
23+
},
24+
"installable": True,
25+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from . import ir_model
2+
from . import res_groups
3+
from . import res_users
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Copyright 2025 Quartile (https://www.quartile.co)
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
4+
from odoo import api, fields, models
5+
6+
7+
class IrModel(models.Model):
8+
_inherit = "ir.model"
9+
10+
restrict_custom_filter_groupby_group_ids = fields.Many2many(
11+
"res.groups",
12+
string="Hide Custom Filter/Group By for Groups",
13+
relation="restrict_custom_filter_groupby_group_rel",
14+
help="Users in these groups will be restricted from seeing the 'Add Custom Filter' "
15+
"and 'Add Custom Group' options in the search view for this model.",
16+
)
17+
18+
restrict_custom_filter_groupby_user_ids = fields.Many2many(
19+
"res.users",
20+
string="Hide Custom Filter/Group By for Users",
21+
relation="restrict_custom_filter_groupby_user_rel",
22+
help="Selected users will be restricted from seeing the 'Add Custom Filter' "
23+
"and 'Add Custom Group' options in the search view for this model.",
24+
)
25+
26+
@api.model
27+
def custom_filter_groupby_is_visible(self, model_name):
28+
model = self.sudo().search([("model", "=", model_name)], limit=1)
29+
if not model:
30+
return True
31+
user = self.env.user
32+
if (
33+
user in model.restrict_custom_filter_groupby_user_ids
34+
or user in model.restrict_custom_filter_groupby_group_ids.users
35+
):
36+
return False
37+
return True
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Copyright 2025 Quartile (https://www.quartile.co)
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
4+
from odoo import fields, models
5+
6+
7+
class ResGroups(models.Model):
8+
_inherit = "res.groups"
9+
10+
restrict_custom_filter_groupby_model_ids = fields.Many2many(
11+
"ir.model",
12+
relation="restrict_custom_filter_groupby_group_rel",
13+
string="Hidden Custom Filter/Group By Models",
14+
help="The users in this group will not see the 'Add Custom Filter' and "
15+
"'Add Custom Group' options in the search view of the selected models.",
16+
)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Copyright 2025 Quartile (https://www.quartile.co)
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
4+
from odoo import fields, models
5+
6+
7+
class ResUsers(models.Model):
8+
_inherit = "res.users"
9+
10+
restrict_custom_filter_groupby_model_ids = fields.Many2many(
11+
"ir.model",
12+
relation="restrict_custom_filter_groupby_user_rel",
13+
string="Hidden Custom Filter/Group By Models",
14+
help="This user will not see the 'Add Custom Filter' and "
15+
"'Add Custom Group' options in the search view of the selected models.",
16+
)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
To Hide “Add Custom Filter” and “Add Custom Group” Options
2+
3+
1. Go to **Settings → Technical → Database Structure → Models**.
4+
2. Open the model where you want to restrict the **“Add Custom Filter”** and
5+
**“Add Custom Group”** options.
6+
3. Set the **"Hide Custom Filter/Group By for Groups"** and/or
7+
**"Hide Custom Filter/Group By for Users"** fields as needed.
8+
If no users or groups are assigned, Odoo will follow its standard behavior, and the
9+
options will remain visible.
10+
11+
Models can also be assigned from the Groups or Users form view by adding them
12+
under the "Hidden Custom Filter/Group By Models" tab.

0 commit comments

Comments
 (0)