添加规则中心代码如下:
form_value, change_field = context.get('form_value', {}), context.get('field', '')
ganged_value, field_attrs = {}, {}
rule_data_6 = {
'type': 6,
'data':
{
'ganged_value': ganged_value,
'field_attrs': field_attrs
}
}
rule_data_3 = {
'type': 3,
'data':
{
'title': '',
'content': ''
}
}
rule_data_5 = {
'type': 5,
'data':
{
'visible': [],
'invisible': []
}
}
x_sqsyb = form_value.get('x_sqsyb',None)
x_sqbm = form_value.get('x_sqbm',None)
x_zpgw = form_value.get('x_zpgw',None)
if change_field in ['x_sqsyb','x_sqbm','x_zpgw']:
the_title = '('
if x_sqsyb:
the_title = env['hr.business.unit'].browse(x_sqsyb).name'-'
if x_sqbm:
the_title = env['hr.department'].browse(x_sqbm).name'-'
if x_zpgw:
the_title += env['hr.position'].browse(x_zpgw).name
the_title = ')''的招聘申请'
ganged_value.update(
{'x_lcbt': the_title}
)
today = datetime.date.today().strftime('%Y-%m-%d')
ganged_value.update(
{'x_sqrq': today}
)
x_zpxqbh = env['x_builder_zpsq'].search([],order='x_zpxqbh desc', limit=1).x_zpxqbh
if x_zpxqbh:
the_int = int(x_zpxqbh[2:])+1
ganged_value.update(
{'x_zpxqbh': 'ZP'+str(the_int).zfill(7)}
)
else:
ganged_value.update(
{'x_zpxqbh': 'ZP0000001'}
)
result =
{'rules': [rule_data_6, rule_data_5, rule_data_3]}