代码:
form_value, change_field = context.get('form_value', {}), context.get('field', '')
ganged_value, field_attrs, tips = {}, {},
{'code': 0, 'msg': ''}
if change_field =='new_department_id':
new_department_id = form_value.get('new_department_id', None)
if new_department_id:
new_dep = env['hr.department'].browse(new_department_id)
ganged_value.update(
{'x_new_department_hrbp_id':new_dep.hrbp_id.id or None}
)
else:
ganged_value.update(
{'x_new_department_hrbp_id':None}
)
rule_data_6 = {
'type': 6,
'data':
{
'ganged_value': ganged_value, 'field_attrs': field_attrs, 'tip': ''
}
}
result =
{'rules': [rule_data_6]}