record = current_approve_instance
value_dict = {
'identification_id': record.x_fd_2020_0160 if record.x_fd_2020_0160 else current_instance_emp.identification_id,
'social_work_start_date': record.x_fd_2020_0135 if record.x_fd_2020_0135 else current_instance_emp.social_work_start_date,
'bank_name': record.x_fd_2020_0161 if record.x_fd_2020_0161 else current_instance_emp.bank_name,
'bank_account': record.x_fd_2020_0162 if record.x_fd_2020_0162 else current_instance_emp.bank_account,
'permanent_residence': record.x_fd_2020_0163 if record.x_fd_2020_0163 else current_instance_emp.permanent_residence,
'registered_permanent_residence': record.x_fd_2020_0164 if record.x_fd_2020_0164 else current_instance_emp.registered_permanent_residence,
'id_address': record.x_fd_2020_0165 if record.x_fd_2020_0165 else current_instance_emp.id_address,
'home_address': record.x_fd_2020_0166 if record.x_fd_2020_0166 else current_instance_emp.home_address,
}
for item in record.x_fd_2020_0148:
if not value_dict.get('worked_ids'):
value_dict['worked_ids'] = [
[0,False,
{'worked_start':item.x_fd_2020_0143,
'worked_end':item.x_fd_2019_0074,
'worked_unit':item.x_fd_2020_0167,
'worked_department':item.x_fd_2020_0168,
'worked_job':item.x_fd_2020_0169}
]]
else:
value_dict['worked_ids'].append(
[0,False,
{'worked_start':item.x_fd_2020_0143,
'worked_end':item.x_fd_2019_0074,
'worked_unit':item.x_fd_2020_0167,
'worked_department':item.x_fd_2020_0168,
'worked_job':item.x_fd_2020_0169}
])
for item in record.x_fd_2020_0154:
ins = env['hr.family.member'].search([('employee_id','=',current_instance_emp.id),('relationship','=',item.x_fd_2020_0174.id)])
if ins:
ins_dict =
{'relationship': item.x_fd_2020_0174.id,
'name': item.x_fd_2020_0176,
'telephone':item.x_fd_2020_0177,
'emergency_contact': True if item.x_fd_2020_0181 == 'x_fd_2020_01811' else False
}
ins.write(ins_dict)
else:
if not value_dict.get('contact_ids'):
value_dict['contact_ids'] = [
[0,False,
{'relationship': item.x_fd_2020_0174.id,
'name': item.x_fd_2020_0176,
'telephone':item.x_fd_2020_0177,
'emergency_contact': True if item.x_fd_2020_0181 == 'x_fd_2020_01811' else False
}
]]
else:
value_dict['contact_ids'].append(
[0,False,
{'relationship': item.x_fd_2020_0174.id,
'name': item.x_fd_2020_0176,
'telephone':item.x_fd_2020_0177,
'emergency_contact': True if item.x_fd_2020_0181 == 'x_fd_2020_01811' else False
}
])
if current_instance_emp:
current_instance_emp.write(value_dict)