Odoo Help


How update values in one2many field using button click?

on 1/8/15, 3:46 AM 1,928 views

I want to update some values in hr.employee to my custom one2many field. How can i add these in a button click?

class hr_employee(osv.osv):
      _inherit = 'hr.employee'

      _columns = { 

                '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'),               
                'location_line_id':fields.many2one('hr.employee','Employee location',ondelete='cascade'),  


def employee_transfer(self, cr, uid, ids, context=None):

      ## How can add one2many values using this function


<button name="location_transfer" type="object" string="(Location Transfer)" context="{'name':name}"/>



I want to update 'own_location' many2one field value in 'current_location' & 'new_location' using a button click?

How can i update one2many field values using button click?


Ankit H Gandhi(AHG)

--Ankit H Gandhi(AHG)--

| 6 5 6
Baroda, India
--Ankit H Gandhi(AHG)--

Learning Python..

Ankit H Gandhi(AHG)
On 1/8/15, 4:03 AM

Hello rosey,

write this code in one2many field in xml file

options="{'reload_on_button': true}"

in your case we can use this code

<field name="location_line_ids" options="{'reload_on_button': true}">

<button string="your string"  name="your method">

Hope this code will be help you..


Ankit H Gandhi


But button is in parent table. is there any issue?

on 1/8/15, 4:21 AM

Hello rosey, there is no any issue, it will work

Ankit H Gandhi(AHG)
on 1/8/15, 7:27 AM

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/8/15, 3:46 AM
Seen: 1928 times
Last updated: 3/16/15, 8:10 AM