Skip to content

Commit c9371c6

Browse files
[ADD] web_hide_custom_filter
1 parent f81f01e commit c9371c6

18 files changed

+760
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../../web_hide_custom_filter
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+
)

web_hide_custom_filter/README.rst

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
===================================
2+
Web Hide Custom Filter and Group-by
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_hide_custom_filter
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_hide_custom_filter
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+
and specific user groups.
34+
35+
**Table of contents**
36+
37+
.. contents::
38+
:local:
39+
40+
Configuration
41+
=============
42+
43+
To show “Add Custom Filter” and “Add Custom Group” options for specific
44+
groups only:
45+
46+
1. Go to **Settings → Technical → Database Structure → Models**.
47+
2. Open the model where you want to control the visibility of the **Add
48+
Custom Filter** and **Add Custom Group** options.
49+
3. Set the **Show Custom Filter/Group By for Groups** field as needed.
50+
If no groups are assigned, Odoo will follow its standard behavior,
51+
and the
52+
options will remain visible.
53+
54+
Alternatively, you can assign models from the Groups form view by adding
55+
them under the "Show 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_hide_custom_filter%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_hide_custom_filter>`_ project on GitHub.
96+
97+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

web_hide_custom_filter/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import models
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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 Hide Custom Filter and Group-by",
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+
],
15+
"assets": {
16+
"web.assets_qweb": [
17+
"web_hide_custom_filter/static/src/xml/*.xml",
18+
],
19+
"web.assets_backend": [
20+
"web_hide_custom_filter/static/src/js/*.esm.js",
21+
],
22+
},
23+
"installable": True,
24+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from . import ir_model
2+
from . import res_groups
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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+
show_custom_filter_groupby_group_ids = fields.Many2many(
11+
"res.groups",
12+
string="Show Custom Filter/Group-by for Groups",
13+
relation="show_custom_filter_groupby_group_rel",
14+
help="Only users in these groups will see the 'Add Custom Filter' "
15+
"and 'Add Custom Group' options in the search view for this model.",
16+
)
17+
18+
@api.model
19+
def custom_filter_groupby_is_visible(self, model_name):
20+
model = self.sudo().search([("model", "=", model_name)], limit=1)
21+
if not model:
22+
return True
23+
groups = model.show_custom_filter_groupby_group_ids
24+
if self.env.user in groups.users or not groups:
25+
return True
26+
return False
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+
show_custom_filter_groupby_model_ids = fields.Many2many(
11+
"ir.model",
12+
relation="show_custom_filter_groupby_group_rel",
13+
string="Show Custom Filter/Group-by Models",
14+
help="Only users in this group will see the 'Add Custom Filter' and "
15+
"'Add Custom Group' options in the search view of the selected models.",
16+
)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
To show “Add Custom Filter” and “Add Custom Group” options for specific groups only:
2+
3+
1. Go to **Settings → Technical → Database Structure → Models**.
4+
2. Open the model where you want to control the visibility of the
5+
**Add Custom Filter** and **Add Custom Group** options.
6+
3. Set the **Show Custom Filter/Group By for Groups** field as needed.
7+
If no groups are assigned, Odoo will follow its standard behavior, and the
8+
options will remain visible.
9+
10+
Alternatively, you can assign models from the Groups form view by adding them
11+
under the "Show Custom Filter/Group By Models" tab.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- [Quartile](https://www.quartile.co):
2+
- Aung Ko Ko Lin

0 commit comments

Comments
 (0)