Optional group by time intervals to use with _date_ and _datetime_ fields
The snippet can be accessed without any authentication.
Authored by
Gabriel Davini
Edited
<!--
You can use a special interval on temporal -date and datetime- fields to alter
the default behaviour of a temporal field search grouping.
The ORM automatically groups the records by 'month', bu you have four other
options: 'day', 'week', 'quarter' and 'year'.
I leave you an example on how to use these:
-->
<search string="Pickings">
<group expand="0" string="Group By">
<filter string="Dayly" domain="[]" context="{'group_by':'min_date:day'}"/>
<filter string="Weekly" domain="[]" context="{'group_by':'min_date:week'}"/>
<filter string="Monthly" domain="[]" context="{'group_by':'min_date'}"/>
<filter string="Quarterly" domain="[]" context="{'group_by':'min_date:quarter'}"/>
<filter string="Yearly" domain="[]" context="{'group_by':'min_date:year'}"/>
</group>
</search>
<!--
You can see a working example here:
https://gitlab.e-mips.com.ar/rafaela-alimentos/logistic_transport/blob/devel/views/delivery_view.xml#L69
And you can read the ORM code that allows us to do this here:
https://github.com/odoo/odoo/blob/8.0/openerp/models.py#L1956
-->
Please register or sign in to comment