This question has been flagged
1 Reply
6019 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):
      _name='employee.location'
      
      
      
      _columns={
              
                '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

xml

<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?

Avatar
Discard
Best Answer

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..

Regards,

Ankit H Gandhi

 

Avatar
Discard
Author

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

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