Skip to content

Commit 5476066

Browse files
[ADD] web_hide_custom_search
1 parent f81f01e commit 5476066

18 files changed

+745
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../../web_hide_custom_search
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_search/README.rst

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
======================
2+
Web Hide Custom Search
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_search
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_search
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 the “Add Custom Filter” and “Add Custom Group” options for a
44+
specific model to specific 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 **Custom Search Groups** field as needed. If no groups are
50+
assigned, Odoo will follow its standard behavior.
51+
52+
Alternatively, you can assign models from the Groups form view by adding
53+
them under the "Custom Search Models" tab.
54+
55+
Bug Tracker
56+
===========
57+
58+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/server-ux/issues>`_.
59+
In case of trouble, please check there if your issue has already been reported.
60+
If you spotted it first, help us to smash it by providing a detailed and welcomed
61+
`feedback <https://github.com/OCA/server-ux/issues/new?body=module:%20web_hide_custom_search%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
62+
63+
Do not contact contributors directly about support or help with technical issues.
64+
65+
Credits
66+
=======
67+
68+
Authors
69+
-------
70+
71+
* Quartile
72+
73+
Contributors
74+
------------
75+
76+
- `Quartile <https://www.quartile.co>`__:
77+
78+
- Aung Ko Ko Lin
79+
80+
Maintainers
81+
-----------
82+
83+
This module is maintained by the OCA.
84+
85+
.. image:: https://odoo-community.org/logo.png
86+
:alt: Odoo Community Association
87+
:target: https://odoo-community.org
88+
89+
OCA, or the Odoo Community Association, is a nonprofit organization whose
90+
mission is to support the collaborative development of Odoo features and
91+
promote its widespread use.
92+
93+
This module is part of the `OCA/server-ux <https://github.com/OCA/server-ux/tree/15.0/web_hide_custom_search>`_ project on GitHub.
94+
95+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

web_hide_custom_search/__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 Search",
5+
"category": "Usability",
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_search/static/src/xml/*.xml",
18+
],
19+
"web.assets_backend": [
20+
"web_hide_custom_search/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: 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+
from odoo import api, fields, models
5+
6+
7+
class IrModel(models.Model):
8+
_inherit = "ir.model"
9+
10+
custom_search_group_ids = fields.Many2many(
11+
"res.groups",
12+
string="Custom Search Groups",
13+
relation="custom_search_group_rel",
14+
help="If set, 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 is_custom_search_visible(self, model_name):
20+
model = self.sudo().search([("model", "=", model_name)], limit=1)
21+
groups = model.custom_search_group_ids
22+
if not model or not groups or self.env.user in groups.users:
23+
return True
24+
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+
custom_search_model_ids = fields.Many2many(
11+
"ir.model",
12+
relation="custom_search_group_rel",
13+
string="Custom Search 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 the “Add Custom Filter” and “Add Custom Group” options for a specific model
2+
to specific groups only:
3+
4+
1. Go to **Settings → Technical → Database Structure → Models**.
5+
2. Open the model where you want to control the visibility of the
6+
**Add Custom Filter** and **Add Custom Group** options.
7+
3. Set the **Custom Search Groups** field as needed.
8+
If no groups are assigned, Odoo will follow its standard behavior.
9+
10+
Alternatively, you can assign models from the Groups form view by adding them
11+
under the "Custom Search 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)