Odoo Help


How to filter contacts of a specific partner?

Anne-Sylvie Burri
on 7/29/13, 11:15 AM 887 views

Hi everybody !

I try to add a selection field in my invoice form. This field must be the contacts of the partner who is selectionned for the invoice.

My xml code is the following :

<?xml version="1.0" encoding="utf-8"?>
<record model="ir.ui.view" id="view_invoice_form">
<field name="name">account.invoice.form.inherit</field>
<field name="model">account.invoice</field>
<field name="type">form</field>
    <field name="inherit_id" ref="account.invoice_form"/>
    <field name="arch" type="xml">
        <field name="fiscal_position" position="after">
                <field name="reference"/>
        <field name="reference" position="after">
                <field name="subject"/>
        <field name="payment_term" position="after">
                <field name="greetings" label="Greetings"/>
        <field name="date_due" position="after">
                <field name="contacts" widget="selection"/>
        <field name="date_invoice" position="after">
                <field name="contact" widget="selection"/>

and my .py code is the following :

from openerp.osv import fields, osv

class account_invoice(osv.osv):
    _inherit = 'account.invoice'
    _defaults = {
        'greetings': lambda *a: "Thanking you for your consideration and with kind regards.",
    _columns = {
        'subject': fields.text('Subject',size=300,required=True,translate=True),
        'reference': fields.text('Reference',size=300,required=True,translate=True),
        'greetings': fields.text('Greetings',size=300,required=True,translate=True),
        'contact': fields.many2one('res.users', 'Further inquiries',readonly=True, track_visibility='always', states={'draft':[('readonly',False)]}),
        'contacts': fields.many2one('res.partner','Contacts'),


The field for which one I want to have the list of the contacts is "contacts".

I thing I have to add a domain to this field but, for the moment, I can't find the correct syntax.

Many thanks in advance for your help.


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.


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

0 follower(s)


Asked: 7/29/13, 11:15 AM
Seen: 887 times
Last updated: 3/16/15, 8:10 AM