When i click the Refresh button below function will call. This one2many field is in hr.employee model.
def button_click(self, cr, uid, ids, context=None):
if context is None:
context = {}
res = self.pool.get('ir.actions.act_window').for_xml_id(cr, uid ,'employee_profile','action_project', context=context)
res['context'] = context
emp_ids_browse = self.browse(cr, uid, ids, context=context)[0].project_line_ids // project_line_ids -- one2many field in hr.employee table. I have an employee_id field in the employee.project table. I want to sort the records based on employee ids. Want to display in the same page.Here the issue is emp_ids_browse didnt browse any records. I want to display all records based on employee_id. But now it is displaying all employee records in all employee profile. How can i get values in emp_ids_browse and sorting will based on employee_id?
print "emp_ids_browse",emp_ids_browse
emp_ids=[]
for emp in emp_ids_browse:
emp_ids.append(emp.id)
print "emp_ids",emp_ids
res['project_line_ids'] = [('id','in', emp_ids)]
return res
I dont want to create as a new record. Just want to display the exiting records in employee.project to hr.employee, in each employee profile
So, the objective is to show "the same" one2many fields in 2 tables in different sorting order? Any reason why not "fix" the sorting order in the original field? I understand that you have hr.employee and employee.projects, linked by employee_id in employee.projects. Is the Refresh button in the view that belongs to hr.employee? If so, isn't sorting by employee_id will be meaningless anyway because for each hr.employee the project_line_ids will only have 1 employee_id?