Odoo Help


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

on 1/6/15, 1:21 AM 1,753 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?

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.


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

1 follower(s)


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