Odoo Help

Welcome!

This community 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.

1

Order in groupby view

By
David Verove
on 2/4/15, 11:16 AM 791 views

Hello,

I can manage ordering in a tree view with "_order = xxx" option in an object, but when I use a group by filter, this order is lost.

I have to order a column by hand to keep this order on the groupby view.

Does anyone know how to set an order by in a group by filter used by default?

Thanks,

David

2

Cyril Gaspard (GEM)

--Cyril Gaspard (GEM)--
4136
| 5 6 8
Paris, France
--Cyril Gaspard (GEM)--

Forum contributor since 2008

Cyril Gaspard (GEM)
On 2/5/15, 8:53 PM

Hi, try to override this method with orderby attribute you want :

https://doc.odoo.com/6.0/developer/2_5_Objects_Fields_Methods/methods/

read_group(cr, uid, domain, fields, groupby, offset=0, limit=None, context=None, orderby=False)

Get the list of records in list view grouped by the given groupby fields

Parameters:

  • cr -- database cursor

  • uid -- current user id

  • domain -- list specifying search criteria [['field_name', 'operator', 'value'], ...]

  • fields -- list of fields present in the list view specified on the object

  • groupby -- list of fields on which to groupby the records

  • offset -- optional number of records to skip

  • limit -- optional max number of records to return

  • context -- context arguments, like lang, time zone

  • order -- optional order by specification, for overriding the natural sort ordering of the groups, see also search() (supported only for many2one fields currently)

It works! I search for my group by vue in groupby argument, then I set a value to order_by on the colums I want. Thanks a lot, David

David Verove
on 2/6/15, 3:20 AM
0

deep

--deep--
1617
| 5 4 7
Bengaluru, India
--deep--

Techno-Functional Associate with 6+ years of experience in Odoo (formerly known as OpenERP).

deep
On 2/5/15, 10:30 AM

As fas as I know, I dont think you can set ordering criteria on group by... if you had noticed,  in the database query level only when you have aggregate functions/group by clause, you cannot straight way order it on the resultant data..

hence same way happens in odoo group by also...

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

2 follower(s)

Stats

Asked: 2/4/15, 11:16 AM
Seen: 791 times
Last updated: 3/16/15, 8:10 AM