I have two different menu: HR-Employee and another is Employee location. In Employee location i will add the locations against each employees. Then i need an extra addons- ie, i want to see the history of these employee locations in their, each employee profile. So i added employee.location model as one2many in my employee profile(hr.employee). And added a button click. For an example, i added 3 records of employee sam in Employee location. Next i select HR-employee and select sam, there is a one2many field in sam's(employee profile). Above to the one2many field there is button. when i click the button it will select 3 records from the employee.location table, and will just display the records in the one2many field. I need this requirement. When i display the records in hr.employee, the id should be the same no duplication is allowed. I just want to display records in the one2many field.
def button_dummy(self, cr, uid, ids, context=None):
res = []
valiue = {}
print "employee",context,ids
ename = context.get('employee_id');
emp_obj = self.pool.get('hr.employee')
emp_name = emp_obj.search(cr, uid, [('name','=',ename)], context=context)
print "emp_name",emp_name
location_lines = []
location_ids = self.pool.get('employee.location').search(cr, uid, [('employee_id','=',emp_name)],limit=5)
for p in self.pool.get('employee.location').browse(cr, uid, location_ids):
location_lines.append((0,0,{'current_location':p.current_location.name
},{'location_type':p.location_type
}))
## First i used this return to update the one2many field, but no output
res['value']['location_line_ids']=location_lines
return res
## Second i used this return to update the one2many field, but no output
return {'value': {'location_line_ids': location_lines}}
How can i display records into one2many field using button click?
First i created employee.location model. Then i call employee.location(one2many) model in hr.employee. In employee.location there is a many2one employee_id field to connect both the models.
<button name="button_dummy" string="Refresh" type="object" context="{'employee_id':name,'location_line_ids':location_line_ids}"/>
<field name="location_line_ids" options="{'reload_on_button': true}">
When i click the button above function will call and just display the employee location data for only displaying. I dont want to write the datas again, only want to display the datas in each employee profile using employee_id.
Waaaaaaw
What happen,do you know the answer?