如何从Odoo的'Many2one'字段中取出'contact'值?

时间:2022-01-24 20:23:39

Any Many2one field which is either linked to hr.employee or res.users shows values Home addresses or contacts in the Many2one drop down tool. Anyone has a suggestion on how to stop this ?

任何链接到hr.employee或res.users的Many2one字段在Many2one下拉工具中显示值Home地址或联系人。有人建议如何制止这个?

1 个解决方案

#1


1  

You can use domain filter to avoid unwanted results.

您可以使用域过滤器来避免不必要的结果。

For Eg:- In sale order we only see customers although its related object is res.patner, Its because of domain filter( please see the code )

例如: - 在销售订单中我们只看到客户,虽然其相关对象是res.patner,因为域名过滤器(请参阅代码)

                            <field name="partner_id" on_change="onchange_partner_id(partner_id, context)" domain="[('customer','=',True)]" context="{'search_default_customer':1, 'show_address': 1}" options='{"always_reload": True}'/>

Here domain filter is " domain="[('customer','=',True)]" "

这里的域名过滤器是“domain =”[('customer','=',True)]“”

ie. records with only customer field is True is shown

即。显示仅客户字段为True的记录

From your comments:- If you want to see system users only then user res.users instead of res.partner. Like:-

从您的评论中: - 如果您只想查看系统用户,请使用res.users而不是res.partner。喜欢:-

        'user_id' : fields.many2one('res.users', 'User')

Hope this helps.

希望这可以帮助。

#1


1  

You can use domain filter to avoid unwanted results.

您可以使用域过滤器来避免不必要的结果。

For Eg:- In sale order we only see customers although its related object is res.patner, Its because of domain filter( please see the code )

例如: - 在销售订单中我们只看到客户,虽然其相关对象是res.patner,因为域名过滤器(请参阅代码)

                            <field name="partner_id" on_change="onchange_partner_id(partner_id, context)" domain="[('customer','=',True)]" context="{'search_default_customer':1, 'show_address': 1}" options='{"always_reload": True}'/>

Here domain filter is " domain="[('customer','=',True)]" "

这里的域名过滤器是“domain =”[('customer','=',True)]“”

ie. records with only customer field is True is shown

即。显示仅客户字段为True的记录

From your comments:- If you want to see system users only then user res.users instead of res.partner. Like:-

从您的评论中: - 如果您只想查看系统用户,请使用res.users而不是res.partner。喜欢:-

        'user_id' : fields.many2one('res.users', 'User')

Hope this helps.

希望这可以帮助。