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.

1

how to use onchange in OpenERP v7

By
More9ike
on 6/14/13, 9:14 AM 4,134 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--
6083
| 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

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

0 follower(s)

Stats

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