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