Odoo Help

7

4
8 Answers
13
Ildar
10‏/11‏/2015 11:31 م

It's better do it this way:

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

Felipe

--Felipe--

1087
| 5 5 10
Bogotá, كولومبيا
--Felipe--
Informatics engineer Industrial engineer
Felipe
29‏/7‏/2013 3:44 م

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

2 Comments
Vivekrajan
8‏/10‏/2013 9:11 ص

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

PT SIVI
17‏/2‏/2014 8:07 ص

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

1
Alex Gallien
1‏/9‏/2015 8:14 م

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.

your_module.py

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)
}

your_module_view.xml

       <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"/>
</field>
</field>
</record>
<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'}"/>
</xpath>
</field>
</record>

Hope that helps someone!

2 Comments
Gustavo
1‏/10‏/2015 11:17 ص

Thank you so much :D

Alex Gallien
1‏/10‏/2015 2:33 م

No problem - glad it helped!

Ask a Question
Writer
Keep Informed
2 follower(s)
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.

Register
Odoo Training Center

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

Test it now