Skip to Content
Menu
This question has been flagged
2 Replies
7092 Views

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

Avatar
Discard
Best Answer

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.

Avatar
Discard

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

Author Best Answer

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),

Avatar
Discard
Related Posts Replies Views Activity
2
Apr 22
7177
3
Jan 19
5972
0
Jun 15
2988
1
Apr 15
5387
1
Mar 15
3868