跳至内容
菜单
此问题已终结
2 回复
8222 查看

Hell Community,

I want to filter partners as is_company=True in many2one field

Here is my code :


<notebook>

<page string="Distributor Line">

<field name="distributor_line" widget="one2many" nolabel="1">

<tree editable="bottom">

<field name="partner_id" string="Customer Name"

on_change="on_change_partner(partner_id)"/>

<field name="x_cus_phone"/>

<field name="x_cus_email"/>

</tree>

</field>

</page>

</notebook>

in py file :


'partner_id': fields.many2one('res.partner', 'Customer Name', ondelete='cascade', select=True),
 

Does any one help me please.

Thanks in advance

形象
丢弃
最佳答案

Hi, 

you can achieve in two ways

1) Make your field defination like below.

'partner_id': fields.many2one('res.partner', 'Customer Name', ondelete='cascade', select=True, domain=[('is_company', '=', True)] ),

2) You can also define your view as like below.

<field name="partner_id" string="Customer Name" domain="[('is_company','=','True')]"

on_change="on_change_partner(partner_id)"/>

I hope it will help you.

形象
丢弃

ohh, I just post my answer and see that you got it.

编写者 最佳答案

I got the solution.


in xml :


<notebook>

<page string="Distributor Line">

<field name="distributor_line" widget="one2many" nolabel="1">

<tree editable="bottom">

<field name="partner_id" string="Customer Name"

on_change="on_change_partner(partner_id)" domain="[('is_company','=','True')]"/>

<field name="x_cus_phone"/>

<field name="x_cus_email"/>

</tree>

</field>

</page>

</notebook>


and in py

'partner_id': fields.many2one('res.partner', 'Customer Name', select=2),

形象
丢弃
相关帖文 回复 查看 活动
2
2月 25
8706
3
1月 19
7253
0
6月 15
4057
1
4月 15
6797
1
3月 15
5167