Odoo Help

Welcome!

This community 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.

0

How to filter contacts of a specific partner?

By
Anne-Sylvie Burri
on 7/29/13, 11:15 AM 619 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"?>
<openerp>
<data>
<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">
        <data>
        <field name="fiscal_position" position="after">
                <field name="reference"/>
        </field>
        <field name="reference" position="after">
                <field name="subject"/>
        </field>
        <field name="payment_term" position="after">
                <field name="greetings" label="Greetings"/>
        </field>
        <field name="date_due" position="after">
                <field name="contacts" widget="selection"/>
        </field>
        <field name="date_invoice" position="after">
                <field name="contact" widget="selection"/>
        </field>
        </data>
    </field>
</record>
</data>
</openerp>

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

account_invoice()

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.

JMB

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

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