I have two model, one is the base model - hr.employee, other one a custom model - employee.employee.
Employee(hr.employee) model contains a new field named Project(many2one field - project.project)
Project(project.project) model contains contains a new field named Location field(many2one field - location.location)
Three fields in employee.employee custom model.
employee_id' : fields.many2one('hr.employee','Employee Name'),
source_location':fields.related('employee_id','project_id',type='many2one',readonly=True,relation='location.location',string='Source Location'),
project':fields.related('employee_id','project_id',type='many2one',readonly=True,relation='project.project',string='Current Project'),
}
def on_change_employee_id(self, cr, uid, ids, employee_id, context=None):
values1 = {}
if not employee_id:
return values1
employee1 = self.pool.get('hr.employee').browse(cr, uid, employee_id, context=context)
print employee1.project_id.name,employee1.project_id.location.name
values1.update({
'source_location' : employee1.project_id.location and employee1.project_id.location.id or False,
'project' : employee1.project_id and employee1.project_id.id or False,
})
print "values1",values1
return {'value' : values1}
I want to update source location and project when the employee onchange occurs. When i print before update and after update the values are correct, when i save the record source location shows wrong. what should be the error?