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 create a new field with contact which depend of the customer in invoice form ?

By
Anne-Sylvie Burri
on 4/23/13, 7:32 AM 1,186 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.

JMB

0

Francesco OpenCode

--Francesco OpenCode--
3608
| 5 7 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)]">
0
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 = {

'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',required=True, readonly=True, states={'draft':[('readonly',False)]}), }

account_invoice()

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

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