Skip to content

Commit 8be644e

Browse files
committed
Draft:[16.0][ADD] web_filter_header_button
1 parent d27d8cc commit 8be644e

22 files changed

Lines changed: 1065 additions & 0 deletions
Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
.. image:: https://odoo-community.org/readme-banner-image
2+
:target: https://odoo-community.org/get-involved?utm_source=readme
3+
:alt: Odoo Community Association
4+
5+
=============
6+
Filter Button
7+
=============
8+
9+
..
10+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
11+
!! This file is generated by oca-gen-addon-readme !!
12+
!! changes will be overwritten. !!
13+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
14+
!! source digest: sha256:329df6eb8c7d4f5db280601a3416d14460c294c342081e38909eabc689074bcf
15+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
16+
17+
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
18+
:target: https://odoo-community.org/page/development-status
19+
:alt: Beta
20+
.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png
21+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
22+
:alt: License: AGPL-3
23+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github
24+
:target: https://github.com/OCA/web/tree/16.0/web_filter_header_button
25+
:alt: OCA/web
26+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
27+
:target: https://translation.odoo-community.org/projects/web-16-0/web-16-0-web_filter_header_button
28+
:alt: Translate me on Weblate
29+
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
30+
:target: https://runboat.odoo-community.org/builds?repo=OCA/web&target_branch=16.0
31+
:alt: Try me on Runboat
32+
33+
|badge1| |badge2| |badge3| |badge4| |badge5|
34+
35+
This module allows to add some selected filters as buttons in the header
36+
control panel.
37+
38+
**Table of contents**
39+
40+
.. contents::
41+
:local:
42+
43+
Use Cases / Context
44+
===================
45+
46+
This developement is aimed to ease the filter access for touch screens
47+
users.
48+
49+
Configuration
50+
=============
51+
52+
To show a filter in the header of the views, it should have the a
53+
``context`` attribute with the key ``shown_in_panel``.
54+
55+
.. code:: xml
56+
57+
<filter
58+
string="My filter"
59+
name="my_filter"
60+
domain="[('active', '!=', False)]"
61+
context="{'shown_in_panel': True}"
62+
>
63+
64+
This will show the filter in the header with its name. You can customize
65+
the button adding an icon or with a custom name passing an object to
66+
that key:
67+
68+
.. code:: python
69+
70+
{'shown_in_panel': {'icon': 'fa-thumbs-up', 'name': 'Ok'}}
71+
72+
You might be interested in leaving just the icon. In that case, set an
73+
empty string on the ``name`` property:
74+
75+
.. code:: python
76+
77+
{'shown_in_panel': {'icon': 'fa-thumbs-up', 'name': ''}}
78+
79+
You could also want to add a hotkey. In such case add the ``hotkey``
80+
property:
81+
82+
.. code:: python
83+
84+
{'shown_in_panel': {'icon': 'fa-thumbs-up', 'hotkey': 'F'}}
85+
86+
You can show filter, groups or even favorites.
87+
88+
Usage
89+
=====
90+
91+
In a search view with header filter buttons, you'll see a filter icon
92+
(funnel). Use it to unfold the filters.
93+
94+
There's a demo implementation in ``Apps`` and you can play around
95+
following the *Configure* section.
96+
97+
Known issues / Roadmap
98+
======================
99+
100+
- Group filters by kind
101+
- As we use the ``context`` attribute, the inheritance could be limiting
102+
in some cases. Keep it in mind or use
103+
``base_view_inheritance_extension`` if you want to use proper context
104+
inheritance.
105+
- Another nice to have would be to be able to hide the filters in the
106+
filter list to be able to show them just in the header, although
107+
there's not a straigh forward way to do it and it could lead to side
108+
effects.
109+
110+
Bug Tracker
111+
===========
112+
113+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/web/issues>`_.
114+
In case of trouble, please check there if your issue has already been reported.
115+
If you spotted it first, help us to smash it by providing a detailed and welcomed
116+
`feedback <https://github.com/OCA/web/issues/new?body=module:%20web_filter_header_button%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
117+
118+
Do not contact contributors directly about support or help with technical issues.
119+
120+
Credits
121+
=======
122+
123+
Authors
124+
-------
125+
126+
* Tecnativa
127+
* Therp Bv
128+
129+
Contributors
130+
------------
131+
132+
- `Tecnativa <https://tecnativa.com>`__
133+
134+
- David Vidal
135+
136+
- `Therp Bv <https://therp.nl>`__
137+
138+
Maintainers
139+
-----------
140+
141+
This module is maintained by the OCA.
142+
143+
.. image:: https://odoo-community.org/logo.png
144+
:alt: Odoo Community Association
145+
:target: https://odoo-community.org
146+
147+
OCA, or the Odoo Community Association, is a nonprofit organization whose
148+
mission is to support the collaborative development of Odoo features and
149+
promote its widespread use.
150+
151+
This module is part of the `OCA/web <https://github.com/OCA/web/tree/16.0/web_filter_header_button>`_ project on GitHub.
152+
153+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

web_filter_header_button/__init__.py

Whitespace-only changes.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Copyright 2026 Therp Bv
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
{
4+
"name": "Filter Button",
5+
"version": "16.0.1.0.0",
6+
"summary": "Show selected filters as buttons in the control panel",
7+
"author": "Tecnativa, Therp Bv, Odoo Community Association (OCA)",
8+
"license": "AGPL-3",
9+
"category": "Server UX",
10+
"website": "https://github.com/OCA/web",
11+
"depends": ["web"],
12+
"data": [],
13+
"demo": [
14+
"demo/ir_module_module_view.xml",
15+
],
16+
"assets": {
17+
"web.assets_backend": [
18+
"web_filter_header_button/static/src/scss/filter_header_buttons.scss",
19+
"web_filter_header_button/static/src/control_panel/control_panel_patch.js",
20+
"web_filter_header_button/static/src/control_panel/control_panel.xml",
21+
"web_filter_header_button/static/src/filter_button/filter_button.js",
22+
"web_filter_header_button/static/src/filter_button/filter_button.xml",
23+
"web_filter_header_button/static/src/search/search_model_patch.js",
24+
"web_filter_header_button/static/src/search/search_arch_parser_patch.js",
25+
],
26+
},
27+
"installable": True,
28+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<odoo>
3+
<record id="view_module_filter" model="ir.ui.view">
4+
<field name="model">ir.module.module</field>
5+
<field name="inherit_id" ref="base.view_module_filter" />
6+
<field name="arch" type="xml">
7+
<filter name="installed" position="attributes">
8+
<attribute
9+
name="context"
10+
>{'shown_in_panel': {'icon': 'fa-toggle-on', 'hotkey': 'i'}}</attribute>
11+
</filter>
12+
<filter name="not_installed" position="attributes">
13+
<attribute
14+
name="context"
15+
>{'shown_in_panel': {'icon': 'fa-toggle-off', 'hotkey': 'u'}}</attribute>
16+
</filter>
17+
<filter name="state" position="attributes">
18+
<attribute
19+
name="context"
20+
>{'group_by':'state', 'shown_in_panel': {'icon': 'fa-th-list', 'hotkey': 's'}}</attribute>
21+
</filter>
22+
</field>
23+
</record>
24+
</odoo>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Translation of Odoo Server.
2+
# This file contains the translation of the following modules:
3+
#
4+
msgid ""
5+
msgstr ""
6+
"Project-Id-Version: Odoo Server 16.0\n"
7+
"Report-Msgid-Bugs-To: \n"
8+
"Last-Translator: Automatically generated\n"
9+
"Language-Team: none\n"
10+
"Language: it\n"
11+
"MIME-Version: 1.0\n"
12+
"Content-Type: text/plain; charset=UTF-8\n"
13+
"Content-Transfer-Encoding: \n"
14+
"Plural-Forms: nplurals=2; plural=n != 1;\n"
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Translation of Odoo Server.
2+
# This file contains the translation of the following modules:
3+
#
4+
msgid ""
5+
msgstr ""
6+
"Project-Id-Version: Odoo Server 16.0\n"
7+
"Report-Msgid-Bugs-To: \n"
8+
"Last-Translator: \n"
9+
"Language-Team: \n"
10+
"MIME-Version: 1.0\n"
11+
"Content-Type: text/plain; charset=UTF-8\n"
12+
"Content-Transfer-Encoding: \n"
13+
"Plural-Forms: \n"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[build-system]
2+
requires = ["whool"]
3+
build-backend = "whool.buildapi"
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
To show a filter in the header of the views, it should have the a `context` attribute with the key `shown_in_panel`.
2+
3+
```xml
4+
<filter
5+
string="My filter"
6+
name="my_filter"
7+
domain="[('active', '!=', False)]"
8+
context="{'shown_in_panel': True}"
9+
>
10+
```
11+
12+
This will show the filter in the header with its name. You can customize the button
13+
adding an icon or with a custom name passing an object to that key:
14+
15+
```python
16+
{'shown_in_panel': {'icon': 'fa-thumbs-up', 'name': 'Ok'}}
17+
```
18+
19+
You might be interested in leaving just the icon. In that case, set an empty string on
20+
the `name` property:
21+
22+
```python
23+
{'shown_in_panel': {'icon': 'fa-thumbs-up', 'name': ''}}
24+
```
25+
26+
You could also want to add a hotkey. In such case add the `hotkey` property:
27+
28+
```python
29+
{'shown_in_panel': {'icon': 'fa-thumbs-up', 'hotkey': 'F'}}
30+
```
31+
32+
You can show filter, groups or even favorites.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This developement is aimed to ease the filter access for touch screens users.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
- [Tecnativa](https://tecnativa.com)
2+
- David Vidal
3+
- [Therp Bv](https://therp.nl)

0 commit comments

Comments
 (0)