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.

3

Order one2many lines

By
Francesco OpenCode
on 8/26/13, 1:45 PM 3,650 views

Is possible to order the line in a one2many without to modify the original class order?

This could be also useful for open a tree view with a particular order by clause... maybe a context parameter like order_by?

TheBrush
on 8/26/13, 1:53 PM

Finally, was it possible? Now I have the same question.

Juan Formoso
on 2/5/15, 12:03 PM
2
Juan Formoso
On 2/6/15, 9:56 AM

Finally, I found a way to manage this, downloading this module:

https://www.odoo.com/apps/modules/7.0/one2many_sorted/

Then, I overrided the one2many whose order I want to alter, in my case the field was child_ids, and I wanted it to be ordered by email:

'child_ids' : one2many_sorted.one2many_sorted(
    'res.partner',
    'parent_id',
    'Contacts',
    order='email',
)

Note that the only difference between this field and the one2many is the param order (you can use a couple new more though, search and set).

I also imported the library at the top of the file:

import one2many_sorted

Now, I'm seeing the tree and kanban of res.partner ordered by name, but this one2many is ordered by email. Great!

well done Juan !! :)

chesucr
on 2/6/15, 10:02 AM

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: 8/26/13, 1:45 PM
Seen: 3650 times
Last updated: 3/27/15, 6:38 PM