-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TA#66767 [MIG][16.0] web_search_date_range (#130)
* TA#66767 [MIG][16.0] web_search_date_range * TA#66767 [MIG][16.0] web_search_date_range * TA#66767 [MIG][16.0] web_search_date_range * TA#66767 [MIG][16.0] web_search_date_range * TA#66767 [IMP] web_search_date_range : module overall quality TA#66767 [IMP] web_search_date_range : module overall quality --------- Co-authored-by: Lanto R. <[email protected]>
- Loading branch information
1 parent
be26220
commit 35cb1fe
Showing
27 changed files
with
1,056 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
===================== | ||
Web Search Date Range | ||
===================== | ||
|
||
.. contents:: Table of Contents | ||
|
||
Context | ||
------- | ||
Vanilla Odoo comes with a predefined set of date range filters. | ||
|
||
.. image:: static/description/vanilla_odoo_filters.png | ||
|
||
There are multiple issues with these filters: | ||
|
||
* They can not be customized (at least without extra javascript code). | ||
* They are based on static dates, which is not suitable for dashboards (you don't want to update your dashboard every month). | ||
* Quarters are only relevant for a company with a fiscal exercise from January to December. | ||
|
||
Overview | ||
-------- | ||
This module allows to easily add contextual date range filters. | ||
|
||
Contextual means that the filter does not need to be updated. | ||
It always filters records based on the current date. | ||
|
||
You may add one of these filters to your favorites or your dashboard and it will not need to be refreshed. | ||
|
||
.. image:: static/description/quotations_list.png | ||
|
||
Configuration | ||
------------- | ||
|
||
Date Filters | ||
************ | ||
To edit the list of filters that appear in the search view of a model: | ||
|
||
* Go to: Settings / Technical / User Interface / Date Filters | ||
|
||
.. image:: static/description/date_filters.png | ||
|
||
After editing the filters, you need to refresh your page for the changes to be applied. | ||
|
||
Date Ranges | ||
*********** | ||
The module comes with the following predefined date ranges: | ||
|
||
* Before Today | ||
* Today | ||
* Next Fifteen Days | ||
* Previous Week | ||
* Current Week | ||
* Next Week | ||
* Previous Month | ||
* Current Month | ||
* Next Month | ||
* Previous Year | ||
* Current Year | ||
* Next Year | ||
|
||
To add a custom range type: | ||
|
||
* Go to: Settings / Technical / User Interface / Date Ranges | ||
|
||
.. image:: static/description/date_range_list.png | ||
|
||
* Click on `Create`. | ||
|
||
.. image:: static/description/date_range_form.png | ||
|
||
* Enter a label for your range type. | ||
* Enter a domain filter for your new range type. | ||
|
||
.. image:: static/description/date_range_with_domain.png | ||
|
||
The following variables can be used inside the domain: | ||
|
||
* field: the technical name of the field being queried | ||
* today: the current date in the timezone of the user | ||
* datetime: the datetime.datetime class | ||
* relativedelta: the dateutil.relativedelta.relativedelta class | ||
* MO, TU, WE, TH, FR, SA, SU: dateutil.relativedelta.weekdays | ||
|
||
See the library `relativedelta <https://dateutil.readthedocs.io/en/stable/relativedelta.html>`_ for more info. | ||
|
||
Weekly Date Ranges | ||
------------------ | ||
Weekly date ranges are implemented from monday to sunday. | ||
|
||
If you prefer from sunday to saturday: | ||
|
||
* Go to: Settings / Technical / User Interface / Date Range Types. | ||
* For each weekly range type: | ||
1. Adapt the domain. | ||
2. Check the `No Update` checkbox. | ||
|
||
.. image:: static/description/demo_date_range.png | ||
|
||
Contributors | ||
------------ | ||
* Numigi (tm) and all its contributors (https://bit.ly/numigiens) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Copyright 2023-today Numigi and all its contributors (https://bit.ly/numigiens) | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). | ||
|
||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Copyright 2023-today Numigi and all its contributors (https://bit.ly/numigiens) | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). | ||
|
||
{ | ||
"name": "Web Search Date Range", | ||
"version": "16.0.1.0.0", | ||
"author": "Numigi", | ||
"maintainer": "Numigi", | ||
"website": "https://bit.ly/numigi-com", | ||
"license": "LGPL-3", | ||
"category": "Project", | ||
"summary": "Add date range filters to the search filters dropdown menu.", | ||
"depends": [ | ||
"web", | ||
], | ||
"data": [ | ||
"security/ir.model.access.csv", | ||
"data/search_date_range.xml", | ||
"views/search_date_range_views.xml", | ||
"views/search_date_range_filter_views.xml", | ||
], | ||
"assets": { | ||
"web.assets_backend": [ | ||
"/web_search_date_range/static/src/js/*", | ||
], | ||
}, | ||
"installable": True, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<odoo> | ||
|
||
<record id="range_before_today" model="search.date.range"> | ||
<field name="label">Before Today</field> | ||
<field name="domain">[ | ||
(field, '<', today.strftime('%Y-%m-%d')), | ||
]</field> | ||
<field name="sequence" eval="-1" /> | ||
</record> | ||
|
||
<record id="range_today" model="search.date.range"> | ||
<field name="label">Today</field> | ||
<field name="domain">[ | ||
'&', | ||
(field, '>=', today.strftime('%Y-%m-%d')), | ||
(field, '<', (today + relativedelta(days=1)).strftime('%Y-%m-%d')), | ||
]</field> | ||
<field name="sequence" eval="1" /> | ||
</record> | ||
|
||
<record id="range_next_fifteen_days" model="search.date.range"> | ||
<field name="label">Next Fifteen Days</field> | ||
<field name="domain">[ | ||
'&', | ||
(field, '>=', today.strftime('%Y-%m-%d')), | ||
(field, '<', (today + relativedelta(days=15)).strftime('%Y-%m-%d')), | ||
]</field> | ||
<field name="sequence" eval="2" /> | ||
</record> | ||
|
||
<!-- Week ranges are from Monday to Sunday --> | ||
<record id="range_previous_week" model="search.date.range"> | ||
<field name="label">Previous Week</field> | ||
<field name="domain">[ | ||
'&', | ||
(field, '>=', (today + relativedelta(days=-today.weekday() - 7)).strftime('%Y-%m-%d')), | ||
(field, '<', (today + relativedelta(days=-today.weekday())).strftime('%Y-%m-%d')), | ||
]</field> | ||
<field name="sequence" eval="3" /> | ||
</record> | ||
|
||
<record id="range_current_week" model="search.date.range"> | ||
<field name="label">Current Week</field> | ||
<field name="domain">[ | ||
'&', | ||
(field, '>=', (today + relativedelta(days=-today.weekday())).strftime('%Y-%m-%d')), | ||
(field, '<', (today + relativedelta(days=-today.weekday() + 7)).strftime('%Y-%m-%d')), | ||
]</field> | ||
<field name="sequence" eval="4" /> | ||
</record> | ||
|
||
<record id="range_next_week" model="search.date.range"> | ||
<field name="label">Next Week</field> | ||
<field name="domain">[ | ||
'&', | ||
(field, '>=', (today + relativedelta(days=-today.weekday() + 7)).strftime('%Y-%m-%d')), | ||
(field, '<', (today + relativedelta(days=-today.weekday() + 14)).strftime('%Y-%m-%d')), | ||
]</field> | ||
<field name="sequence" eval="5" /> | ||
</record> | ||
|
||
<record id="range_previous_month" model="search.date.range"> | ||
<field name="label">Previous Month</field> | ||
<field name="domain">[ | ||
'&', | ||
(field, '>=', (today - relativedelta(days=today.day - 1) + relativedelta(months=-1)).strftime('%Y-%m-%d')), | ||
(field, '<', (today - relativedelta(days=today.day - 1)).strftime('%Y-%m-%d')), | ||
]</field> | ||
<field name="sequence" eval="6" /> | ||
</record> | ||
|
||
<record id="range_current_month" model="search.date.range"> | ||
<field name="label">Current Month</field> | ||
<field name="domain">[ | ||
'&', | ||
(field, '>=', (today - relativedelta(days=today.day - 1)).strftime('%Y-%m-%d')), | ||
(field, '<', (today - relativedelta(days=today.day - 1) + relativedelta(months=1)).strftime('%Y-%m-%d')), | ||
]</field> | ||
<field name="sequence" eval="7" /> | ||
</record> | ||
|
||
<record id="range_next_month" model="search.date.range"> | ||
<field name="label">Next Month</field> | ||
<field name="domain">[ | ||
'&', | ||
(field, '>=', (today - relativedelta(days=today.day - 1) + relativedelta(months=1)).strftime('%Y-%m-%d')), | ||
(field, '<', (today - relativedelta(days=today.day - 1) + relativedelta(months=2)).strftime('%Y-%m-%d')), | ||
]</field> | ||
<field name="sequence" eval="8" /> | ||
</record> | ||
|
||
<record id="range_previous_year" model="search.date.range"> | ||
<field name="label">Previous Year</field> | ||
<field name="domain">[ | ||
'&', | ||
(field, '>=', datetime(today.year - 1, 1, 1).strftime('%Y-%m-%d')), | ||
(field, '<', datetime(today.year, 1, 1).strftime('%Y-%m-%d')), | ||
]</field> | ||
<field name="sequence" eval="9" /> | ||
</record> | ||
|
||
<record id="range_current_year" model="search.date.range"> | ||
<field name="label">Current Year</field> | ||
<field name="domain">[ | ||
'&', | ||
(field, '>=', datetime(today.year, 1, 1).strftime('%Y-%m-%d')), | ||
(field, '<', datetime(today.year + 1, 1, 1).strftime('%Y-%m-%d')), | ||
]</field> | ||
<field name="sequence" eval="10" /> | ||
</record> | ||
|
||
<record id="range_next_year" model="search.date.range"> | ||
<field name="label">Next Year</field> | ||
<field name="domain">[ | ||
'&', | ||
(field, '>=', datetime(today.year + 1, 1, 1).strftime('%Y-%m-%d')), | ||
(field, '<', datetime(today.year + 2, 1, 1).strftime('%Y-%m-%d')), | ||
]</field> | ||
<field name="sequence" eval="11" /> | ||
</record> | ||
|
||
</odoo> |
Oops, something went wrong.