diff options
| author | Adrien Dieudonne <adr@odoo.com> | 2018-07-06 14:22:58 +0200 |
|---|---|---|
| committer | Adrien Dieudonne <adr@odoo.com> | 2018-07-06 14:22:58 +0200 |
| commit | 3ebff1f4721dd4a9057db4d26162c57c8506700a (patch) | |
| tree | e3b02fcc528dcc3a0ae50b55a5d3a1d4708ab992 /doc/reference | |
| parent | f9a68d5e778da0ff4e1f1a0936b51b98a822a15a (diff) | |
| parent | 11b7857af63a35e81daa495bcb3522b3915f32ca (diff) | |
[MERGE] *: Easy date filters
This commit allow to create easily a range of periods (related to a field
of date or datetime type) to select in the filters menu.
Two new attributes on elements with tag 'filter' are now usable
in combination in a search view arch:
- date: string.
A valid field name with associated type date or datetime
- default_period: string (optional).
To choose in the following list:
- 'today'
- 'this_week'
- 'this_month' (default)
- 'this_quarter'
- 'this_year'
- 'yesterday'
- 'last_week'
- 'last_month'
- 'last_quarter'
- 'last_year'
- 'last_7_days'
- 'last_30_days'
- 'last_365_days'
Example:
<filter string="Creation Date" name="period_generator" date="create_date" default_period="this_quarter"/>
Note: the attribute 'domain' can not be used for such filters.
The generated domains are dynamic and can be saved as such
via the favorites menu.
task-10532
Diffstat (limited to 'doc/reference')
| -rw-r--r-- | doc/reference/views.rst | 77 |
1 files changed, 75 insertions, 2 deletions
diff --git a/doc/reference/views.rst b/doc/reference/views.rst index eca2a0ad73f..9093bc314c6 100644 --- a/doc/reference/views.rst +++ b/doc/reference/views.rst @@ -1423,12 +1423,85 @@ Possible children elements of the search view are: ``string`` (required) the label of the filter - ``domain`` + ``domain`` (optional) an Odoo :ref:`domain <reference/orm/domains>`, will be appended to the - action's domain as part of the search domain + action's domain as part of the search domain. + ``date`` (optional) + the name of a field of type ``date`` or ``datetime``. + Using this attribute has the effect to create + a set of filters available in a submenu + of the filters menu. + + Example: + + .. code-block:: xml + + <filter name="filter_create_date" date="create_date" string="Creation Date"/> + + The example above allows to easily search for records with creation date field + values in one of the periods below. + + .. code-block:: text + + Create Date > + Today + This Week + This Month + This Quarter + This Year + -------------- + Yesterday + Last Week + Last Month + Last Quarter + Last Year + -------------- + Last 7 Days + Last 30 Days + Last 365 Days + + Note that the generated domains are dynamic and can be saved as such (via the favorites menu). + + ``default_period`` (optional) + only makes sense for a filter with non empty ``date`` attribute. + determines which period is activated if the filter is in the + default set of filters activated at the view initialization. If not provided, + 'this_month' is used by default. + + To choose among the following options: + today, this_week, this_month, this_quarter, this_year, + yesterday, last_week, last_month, + last_quarter, last_year, last_7_days, last_30_days, last_365_days + + Example: + + .. code-block:: xml + + <filter name="filter_create_date" date="create_date" string="Creation Date" default_period="this_week"/> + ``context`` a Python dictionary, merged into the action's domain to generate the search domain + + The key ``group_by`` can be used to define a groupby available in the + 'Group By' menu. + The 'group_by' value can be a valid field name or a list of field names. + + .. code-block:: xml + + <filter name="groupby_category" string="Category" context = {'group_by': 'category_id'}/> + + The groupby defined above allows to group data by category. + + When the field is of type ``date`` or ``datetime``, the records are grouped by month by default. + This can be modified by using one of the following options: day, week, quarter, year. + + Example: + + .. code-block:: xml + + <filter name="groupby_create_date" string="Creation Date" context = {'group_by': 'create_date:week'}/> + ``name`` logical name for the filter, can be used to :ref:`enable it by default <reference/views/search/defaults>`, can also be used as |
