Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
8172 Widoki

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

Awatar
Odrzuć
Najlepsza odpowiedź

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.

Awatar
Odrzuć

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

Autor Najlepsza odpowiedź

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

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
2
lut 25
8630
3
sty 19
7209
0
cze 15
4017
1
kwi 15
6711
1
mar 15
5076