跳至內容
選單
此問題已被標幟
2 回覆
19872 瀏覽次數

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?

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

最佳答案

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 !! :)

最佳答案

Just  add  attribute default_order  to  tree  view
default_order="date desc"
頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
0
3月 15
4865
0
9月 17
11049
1
1月 25
2244
2
4月 24
2074
1
1月 24
2504