forked from erp-dev/erp
feat: product quick api and param create api
This commit is contained in:
@@ -236,13 +236,13 @@ def can_advance_to_next_state(business_object: 'models.BusinessObject') -> Tuple
|
||||
|
||||
def get_business_object_state_timeline(business_object: 'models.BusinessObject') -> List[dict]:
|
||||
"""
|
||||
获取业务对象状态时间线(包括未开始、进行中和已完成的状态)
|
||||
获取业务对象状态时间线(包括未开始和已完成的状态)
|
||||
|
||||
返回格式:
|
||||
[
|
||||
{
|
||||
'state': State对象,
|
||||
'status': 'not_started' | 'in_progress' | 'completed' | 'cancelled',
|
||||
'status': 'not_started' | 'completed' | 'cancelled',
|
||||
'order': 顺序号,
|
||||
'completed_at': 完成时间(如果已完成),
|
||||
'completed_by': 完成人(如果已完成),
|
||||
@@ -255,8 +255,11 @@ def get_business_object_state_timeline(business_object: 'models.BusinessObject')
|
||||
状态判断规则:
|
||||
- cancelled: 有日志记录且已撤销
|
||||
- completed: 有日志记录且未撤销
|
||||
- in_progress: 没有日志记录,但是 current_state(下一个待执行的节点),且已有完成记录
|
||||
- not_started: 其他未开始的节点
|
||||
- not_started: 没有日志记录(还未完成)
|
||||
|
||||
注意:移除了 'in_progress' 状态,因为在当前设计中:
|
||||
- current_state 表示"下一个待执行的节点",它还未开始执行,所以是 not_started
|
||||
- 一个节点要么已完成,要么还未开始,没有"进行中"的中间状态
|
||||
"""
|
||||
timeline = []
|
||||
process_nodes = business_object.process.process_nodes.select_related('state').order_by('order', 'id')
|
||||
@@ -288,12 +291,9 @@ def get_business_object_state_timeline(business_object: 'models.BusinessObject')
|
||||
cancelled_at = log.cancelled_at
|
||||
is_cancelled = log.is_cancelled
|
||||
else:
|
||||
# 未开始的节点,判断是 in_progress 还是 not_started
|
||||
# 如果是 current_state 且有任何完成记录,则为 in_progress
|
||||
if has_any_completed and state.id == current_state_id:
|
||||
status = 'in_progress'
|
||||
else:
|
||||
status = 'not_started'
|
||||
# 未开始的节点
|
||||
# current_state 是"下一个待执行的节点",它还未开始,所以状态是 not_started
|
||||
status = 'not_started'
|
||||
completed_at = None
|
||||
completed_by = None
|
||||
cancelled_at = None
|
||||
|
||||
Reference in New Issue
Block a user