Odoo Help


select customer and get specific fields value

on 3/10/16, 5:42 AM 814 views

  I'm trying to get 'title' automatically when customer will select. can anyone help me?


class res_partner(osv.osv):

    _name = 'project.task'

    _inherit = 'project.task'

    _columns = {

            'partner_id': fields.many2one('res.partner', string='Employees', groups='base.group_user'),



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

        if partner_id:

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

                return {'value': {'title': partner_id.title,}}

        return {'value':{}}


<field name="partner_id" on_change="onchange_partner_id(title,partner_id)"/>

<field name="title" on_change="onchange_partner_id(title,partner_id)"/>




| 4 4 6
Hyderabad, India

On 3/10/16, 7:55 AM


First, You don't need to pass 'title' as an argument in on_change of partner_id at xml field defination...
then, under onchange_partner_id, u are having partner_id as an argument, but while browsing you are using 'title', which is not defined anywhere in function defination...

so please change title to partner_id in browse, as:

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

and in xml as:

<field name="partner_id" on_change="onchange_partner_id(partner_id)"/>

and no need of any onchange function in title field...

Hope it help!    

Hi, Pawan. Thank you for your reply, I tried with change as you suggest me but still not working, no error and not getting data in title field.

on 3/10/16, 8:16 AM

Hi, Pawan. I change "partner_id" to "customer_project" (just changed the id) and customer_project= self.pool.get('res.partner').browse(cr, uid, customer_project, context=context), and in xml as: now its Working!!

on 3/10/16, 9:09 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

1 follower(s)


Asked: 3/10/16, 5:42 AM
Seen: 814 times
Last updated: 3/10/16, 9:11 AM