Skip to Content
Menu
This question has been flagged
1 Reply
4214 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'),

            'title':fields.char('Tte'),

    }

    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':{}}


xml::

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

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



Avatar
Discard
Best Answer

nahain,

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!    

Avatar
Discard
Author

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.

Author

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!!

Related Posts Replies Views Activity
0
Apr 24
397
4
Nov 23
4244
0
Oct 23
377
0
Dec 22
1334
2
Dec 23
17348