How to set a specific lines order in a one2many field in OpenERP7?

坚强是说给别人听的谎言 提交于 2019-12-13 20:14:17

问题


Is it possible to order lines in a one2many field by a specific column without modifying the original class order?

Let's put an example: The model res.partner is ordered by the field name. So, if you open a res.partner view, the rows are going to be ordered by their name.

Now, I'm in a view of other model. This model has a one2many field pointing to res.partner, this means that I'm seeing a list of partners, and they're ordered by name too.

Can I always see this last list ordered by other column like for example email, but keeping the order by name in res.partner views?


回答1:


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 different 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!



来源:https://stackoverflow.com/questions/28350610/how-to-set-a-specific-lines-order-in-a-one2many-field-in-openerp7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!