forked from erp-dev/erp
feat: query all process nodes for business_object
This commit is contained in:
@@ -476,3 +476,34 @@ def add_parameters_to_state_log(state_log: 'models.StateFlowRecord', remark: str
|
||||
StateLogParameterRecord: 创建的参数记录
|
||||
"""
|
||||
return create_parameter_record(state_log, remark, **parameters)
|
||||
|
||||
|
||||
def get_process_nodes(business_object: 'models.BusinessObject') -> List[dict]:
|
||||
"""
|
||||
获取业务对象所属流程的所有状态节点列表
|
||||
|
||||
参数:
|
||||
business_object: BusinessObject 实例
|
||||
|
||||
返回:
|
||||
节点列表,每个元素包含:
|
||||
{
|
||||
'id': ProcessNode ID,
|
||||
'state': State对象,
|
||||
'state_id': State ID,
|
||||
'state_name': State 名称,
|
||||
'order': 节点顺序号
|
||||
}
|
||||
"""
|
||||
process_nodes = business_object.process.process_nodes.select_related('state').order_by('order', 'id')
|
||||
|
||||
return [
|
||||
{
|
||||
'id': node.id,
|
||||
'state': node.state,
|
||||
'state_id': node.state_id,
|
||||
'state_name': node.state.name,
|
||||
'order': node.order,
|
||||
}
|
||||
for node in process_nodes
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user