Odoo Help


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.


How to update many2one field on the onchange of one2many field?

on 1/6/15, 1:21 AM 919 views

My code:

class hr_employee(osv.osv):

      _inherit = 'hr.employee'

'own_location' : fields.many2one('location.location','Own location'),

'location_line_ids': fields.one2many('employee.location', 'location_line_id', 'Location'),


class employee_location(osv.osv):
                'current_location':fields.char('Current location'),
                'new_location':fields.many2one('location.location','New location'),
                'start_date' : fields.date('Start Date'),
                'end_date' : fields.date('End Date'),    
                'location_line_id':fields.many2one('hr.employee','Employee location',ondelete='cascade'),  

When i select 'new_location' the value of the new_location will have to updated in the 'own_location' many2one fields.

For eg: when i select 'new_location' field in my one2many field, i want to call a onchange function, in that function i want to update the value of  new_location in the 'own_location' many2one field. Before that i want to clear the existng valiue in 'own_location' many2one field. Then will update the value.


How is it possible?

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)


Asked: 1/6/15, 1:21 AM
Seen: 919 times
Last updated: 3/16/15, 8:10 AM