如何在OpenERP7的one2many字段中设置特定的行顺序? [英] How to set a specific lines order in a one2many field in OpenERP7?

查看:69
本文介绍了如何在OpenERP7的one2many字段中设置特定的行顺序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在不更改原始类顺序的情况下按特定列在one2many字段中对行进行排序?

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

让我们举个例子: 型号res.partner由字段 名称 排序.因此,如果打开res.partner视图,则行将按其名称排序.

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.

现在,我在考虑其他模型.该模型有一个指向res.partner的one2many字段,这意味着我看到了一个合作伙伴列表,它们也按名称排序.

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.

我是否可以总是看到其他列(例如 电子邮件 )排序的最后一个列表,但在res.partner视图中按名称保留顺序?

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?

推荐答案

最后,我找到了一种管理此问题的方法,下载了此模块:

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

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

然后,我覆盖了要更改其顺序的one2many,在我的情况下,该字段为child_ids,我希望通过电子邮件对其进行排序:

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( 合作伙伴", 'parent_id', 联系人", order ='email', )

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

请注意,此字段与one2many之间唯一的不同是参数顺序(不过,您可以使用更多新参数进行搜索和设置).

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:

导入one2many_sorted

import one2many_sorted

现在,我看到res.partner的树和看板按名称排序,但是这个one2many是通过电子邮件排序的.太好了!

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

这篇关于如何在OpenERP7的one2many字段中设置特定的行顺序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆