Odoo Help


How to group by day?

on 7/18/13, 7:16 PM 11,983 views

In the search view in a tree view, when I group by date, it always group by month, there is any way to specify to group by day, year or even hour?

Have you found a solution?

on 7/28/13, 2:14 PM
On 11/10/15, 11:31 PM

It's better do it this way:

<filter string="Day" domain="[ ]" context="{'group_by': 'create_date:day'}" />



| 5 5 8
Bogotá, Colombia
Informatics engineer Industrial engineer
On 7/29/13, 3:44 PM

I made a workaround, the idea is that you create a function field(store=True) of type char that copy the date string detail to the function field, the level of detail is determined by that you want to group, if you want to group by day copy the datetime till the day.

Then you add that new field in your groupby filters in the searchview you want

Hey Felipe, Your idea will work for him. This is the way used in most official addons of OpenERP out of the box. This idea works. Just check code of Sales Analysis or Invoice analysis, you will find more useful techniques

on 10/8/13, 9:11 AM

What are the name of directories and files that you pointed out? Thanks

on 2/17/14, 8:07 AM
Alex Gallien
On 9/1/15, 8:14 PM

This is an old question, but I thought I would add some code in case anyone is trying to do this. Mine was adding a sort by day field to account_voucher, so you may need to adjust yours to whatever you are trying to inherit. I am not putting the whole code, just the relevant snippets.


class ec_account_voucher(osv.osv):
_inherit = 'account.voucher'
_name = 'account.voucher'
def _get_string_date(self, cr, uid, ids, name, args, context=None):
res = {}
for voucher in self.browse(cr, uid, ids, context=context):
res[voucher.id] = str(voucher.date)
return res
_columns = {
'x_string_date': fields.function(_get_string_date, type='char', string='Date (String)', store=True)


       <record model="ir.ui.view" id="voucher_form_ec">
<field name="name">account.voucher.tree.inherit</field>
<field name="model">account.voucher</field>
<field name="inherit_id" ref="account_voucher.view_voucher_tree"/>
<field name="arch" type="xml">
<field name="date" position="after">
<field name="x_string_date" invisible="1"/>
<record id="ec_view_voucher_filter" model="ir.ui.view">
<field name="name">account.voucher.select.inherit</field>
<field name="model">account.voucher</field>
<field name="inherit_id" ref="account_voucher.view_voucher_filter_vendor_pay"/>
<field name="arch" type="xml">
<xpath expr="//filter[@string='Status']" position="before">
<filter string="Day" icon="terp-go-month" domain="[]" context="{'group_by':'x_string_date'}"/>

Hope that helps someone!

Thank you so much :D

on 10/1/15, 11:17 AM

No problem - glad it helped!

Alex Gallien
on 10/1/15, 2:33 PM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

2 follower(s)


Asked: 7/18/13, 7:16 PM
Seen: 11983 times
Last updated: 12/14/16, 5:05 AM