Odoo Help


How to create a new field with contact which depend of the customer in invoice form ?

Anne-Sylvie Burri
on 4/23/13, 7:32 AM 1,702 views

Hi everybody,

I try to create a new field in my invoice form. I want to have a "selection" field with the list of the contacts linked with the customer.

I already search an answer on several forums but never find a solution.

Many thanks in advance for your help.



Francesco OpenCode

--Francesco OpenCode--

| 6 8 9
Grottaglie, Italy
--Francesco OpenCode--

Italian Odoo (OpenERP) Modules Developer LINKEDIN: http://www.linkedin.com/in/francescoapruzzese

Francesco OpenCode
On 4/23/13, 8:14 AM

Insert this field after partner_id field in invoice form:

<field name="your_contact_field" widget="selection" domain="[('parent_id', '=', partner_id)]">
Anne-Sylvie Burri
On 4/24/13, 6:34 AM

Thank you for your answer.

I tried and it's ok the field appear in my form but there is no name inside, the field is empty.

Maybe I have to add something in the following definition of the field in python file ?

from openerp.osv import fields, osv

class account_invoice(osv.osv): _inherit = 'account.invoice' _defaults = { 'greetings': lambda *a: "With our thanks and our kind regards.", }
_columns = {




'contact': fields.many2one('res.users', 'Further inquiries',readonly=True, track_visibility='always', states={'draft':[('readonly',False)]}),

'contacts': fields.many2one('res.partner','Contacts',required=True, readonly=True, states={'draft':[('readonly',False)]}), }


Please insert this code in the answer with right format because is unreadable

Francesco OpenCode
on 4/24/13, 7:58 AM

Sorry ! Is it better like this ?

J.-M. Burri - Bureau ing.-conseils informatique, Anne-Sylvie Burri
on 4/24/13, 8:07 AM

The code is right! You must use this code: <field name="contact" widget="selection" domain="[('parent_id', '=', contact)]">

Francesco OpenCode
on 4/24/13, 8:10 AM

Thank you ! I tried with your code but the field is still empty. Maybe the problem is in xml file ?

J.-M. Burri - Bureau ing.-conseils informatique, Anne-Sylvie Burri
on 4/25/13, 4:40 AM

<?xml version="1.0" encoding="utf-8"?> <openerp> <data> <record model="ir.ui.view" id="view_account_invoice_form_inherit"> <field name="name">account.invoice.form</field> <field name="model">account.invoice</field> <field name="type">form</field> <field name="arch" type="xml"> <form string="Invoice"> <field name="subject"/> <field name="greetings"/> <field name="contact"/> <field name="contacts"/> </form> </field> </record> </data> </openerp>

J.-M. Burri - Bureau ing.-conseils informatique, Anne-Sylvie Burri
on 4/25/13, 4:40 AM

I can't improve the format :(

J.-M. Burri - Bureau ing.-conseils informatique, Anne-Sylvie Burri
on 4/25/13, 4:42 AM

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: 4/23/13, 7:32 AM
Seen: 1702 times
Last updated: 3/16/15, 8:10 AM