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 update values in one2many field using button click?

on 1/8/15, 3:46 AM 987 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)--
| 5 3 6
Gandhinagar, 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

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