I have below list value, How can i return this list value into a one2many field?
I tried many ways but no output.
[{'current_location': (1, u'Location 1'), 'id': 60, 'location_type': u'own'}, {'current_location': (1, u'location 1'), 'id': 63, 'location_type': u'own'}]
My python code is :
ename = context.get('employee_id');
emp_obj = self.pool.get('hr.employee')
emp_name = emp_obj.search(cr, uid, [('name','=',ename)], context=context)
location_lines = []
location_ids = self.pool.get('employee.location').search(cr, uid, [('employee_id','=',emp_name)],limit=5)
In this location_ids all records based on employee_id should be as a stored as list.
I want to display the values in list into my one2many field. I want to display the records. dont want to create or write.
I dont know how i overcome the situation. I just want to display values in location_ids into my one2many field in hr.employee. How can i do this using the button click function? Please help me.
hi
hi
What do you mean by return? Looking at your code, employee.location must be linked to hr.employee through employee_id. I hope emp_name is hr.employee's ID. If so, displaying location_ids in the view alone should displayed all employee.location that is linked to the particular hr.employee. The add functionality is also build in if you use one2many_list widget. Where are you implementing this? Within the on_change mechanism? If it is for on_change mechanism and you want to add a value, use [(0, 0, {'current_location':r['current_location'], 'location_type':r['location_type']})]
I'm using button click. when i click the button, all records from the employee.location based on employee_id will display in the one2many field in hr.employee.
Then I would suggest that the view that shows the location to be made for model hr.employee and only display location_ids in the view. If you pass the current active hr.employee's ID to that view in the window action, it should display the locations automatically.
hello