显示
1.提交表单后,回写字段到某个模型的指定记录
例将离职单上的离职原因和离职类型回写到主数据对应字段
self.employee_id.write({
'x_lzlx': self.resignation_type.id or None,
'x_lzyy': self.resignation_reason.id or None,
})
2.规则二的代码案例
说明:当选定了业务单元(business_unit_id)后法人实体(legal_entity_id)只能选择改业务单元上挂的法人实体
form_value, change_field = context.get('form_value', {}), context.get('field', '')
ganged_value, field_attrs = {}, {}
business_unit_id = form_value.get('business_unit_id',None)
business_unit_instance = env ['hr.business.unit'] .browse(business_unit_id)
domain = str([[]])
if business_unit_instance:
domain = str([['code', 'in', [i.code for i in business_unit_instance.legal_entity_ids] ]])
rule_data_2 = {'type': 2, 'data': {'legal_entity_id':
{'domain': domain}
}}
result =
{'rules': [rule_data_2]}
3.提交时候触发对话框
if 1=1:
raise ValidationError('sdfsdfsdfd!!!!')