代码:
form_value, change_field, form_content = context.get('form_value', {}), context.get('field', ''), context.get('form_content', {})
ganged_value, field_attrs = {}, {}
username = form_value.get('username',None)
rule_data_3 = {
'type': 3,
'data':
{
'title': '',
'content': ''
}
}
if change_field=='username' and username:
exist_emp = env['hr.employee'].search([('active','=',True),('username','=',username)])
if exist_emp:
rule_data_3 = {
'type': 3,
'data':
{
'title': '用户名重复!!',
'content': '用户名重复了!!'
}
}
result =
{'rules': [rule_data_3]}