Odoo Help

0

Filter only partner as is_company in many2one field on openerp 7 ?

By
babu
on 6/19/15, 6:17 AM 1,228 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

1

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.

Emipro Technologies Pvt. Ltd.
on 6/19/15, 7:47 AM
0
babu
On 6/19/15, 7:43 AM

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

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)

Stats

Asked: 6/19/15, 6:17 AM
Seen: 1228 times
Last updated: 6/20/15, 1:01 AM