Odoo Help

1

how to use onchange in OpenERP v7

By
More9ike
on 6/14/13, 9:14 AM 4,938 views

Hello all, please I have a model that contains 5 fields e.g employee name, department, job, and manager. I want a situation where if i choose an employee from the lists, the department, job and manager fields are automatically populated.

Please can somebody help me with this?

Thanks

5

Sandeep

--Sandeep--
6123
| 6 5 8
Delhi, India
--Sandeep--
Python OpenERP Developer http://in.linkedin.com/pub/sandeep-rana/3b/a16/786/
Sandeep
On 6/14/13, 10:06 AM

Hi
do it like below:

    def myonchange(self,cr,uid,ids,employee_id,context=None):
       vals={}
       if employee_id:
            obj=self.pool.get('hr.employee').browse(cr,uid,employee_id)
            vals.update({'yourmanger':obj.manager_id.id,'yourjob':obj.job_id.id,'yourdepartment':obj.department_id.id})

       return {'value':vals}

add the the on_change in view in employee_id field

   <field name="employee_id" on_change="myonchange(employee_id)"/>

Thanks
Sandeep

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.

Register

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

0 follower(s)

Stats

Asked: 6/14/13, 9:14 AM
Seen: 4938 times
Last updated: 3/16/15, 8:10 AM