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

select customer and get specific fields value

By
nahian
on 3/10/16, 5:42 AM 382 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)"/>



2

Pawan

--Pawan--
1267
| 4 3 5
Hyderabad, India
--Pawan--


Pawan
On 3/10/16, 7:55 AM

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!    

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.

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

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

1 follower(s)

Stats

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