Odoo Help


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.


Customer name is not saved in Form while click the save button?

on 6/8/15, 11:27 AM 369 views

Hi All,

I have created a form like distributors, in this form distributor_lines need to take customer name(onchange function), phone and email, when i click the save button customer name is not saved, different user name is saved , please help me.

here is my code :

xml file :

<record model="ir.ui.view" id="crm_sale_distributor_view_form">

<field name="name">endo.distributor.form</field>

<field name="model">endo.distributor</field>

<field name="arch" type="xml">

<form string="Sales Distributor" version="7.0">

<group col="5">

<field name="name" style="width: 50%%" />

<field name="dist_id"/>



<notebook colspan="4">

<page string="Distributor Line">

<field name="distributor_line" widget="one2many" nolabel="1">

<tree editable="bottom">

<field name="partner_id" string="Customer Name"


<field name="x_cus_phone"/>

<field name="x_cus_email"/>









py file :

class distributor_lines(osv.osv):

_name = "endo.distributor.lines"

_description="Sales Distributor Lines"

_columns = {

'partner_id': fields.many2one('res.partner', 'Customer Name', ondelete='cascade', select=True),

'x_cus_phone': fields.char('Mobile', size=64),

'x_cus_email': fields.char('Email', size=240),


def on_change_partner(self, cr, uid, ids, partner_id, context=None):

values = {}

if partner_id:

partner = self.pool.get('res.partner').browse(cr, uid, partner_id, context=context)

values = {

'x_cus_email' : partner.email,

'x_cus_phone' : partner.phone,


print "values", values

return {'value' : values}


class endo_distributor(osv.osv):

_name = 'endo.distributor'

_description="Sales Distributors"


'name':fields.char('Distributor Name', size=128, required=True),

'dist_id': fields.many2one('res.partner', 'Partner'),

'distributor_line': fields.one2many('endo.distributor.lines', 'partner_id', 'Distributor Lines'),



Thanks in advance

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

1 follower(s)


Asked: 6/8/15, 11:27 AM
Seen: 369 times
Last updated: 6/8/15, 11:28 AM