forked from erp-dev/erp
fix: current_state has been changed to a computed property
This commit is contained in:
@@ -135,28 +135,16 @@ class PlateOrder(ModelBase):
|
||||
@property
|
||||
def status(self) -> str:
|
||||
"""
|
||||
返回当前状态名称(下一个待执行的状态名称)
|
||||
返回当前状态名称
|
||||
|
||||
规则:
|
||||
- current_state 为 None:返回"已完成"(没有待执行的节点)
|
||||
- current_state 不为 None + 进度 0%:返回"未开始"
|
||||
- current_state 不为 None + 进度 > 0%:返回 current_state.name(正在进行)
|
||||
- current_state 为 None:返回"已完成"
|
||||
- 否则:返回 current_state 的名称
|
||||
|
||||
注意:废除了"未开始"的概念,直接显示节点名称
|
||||
"""
|
||||
if not self.business_object:
|
||||
return '未开始'
|
||||
|
||||
current_state = self.business_object.get_current_state()
|
||||
|
||||
if current_state is None:
|
||||
# 没有待执行的节点,已完成
|
||||
return '已完成'
|
||||
|
||||
# 有待执行的节点,配合进度判断是"未开始"还是"进行中"
|
||||
progress = self.business_object.get_progress_percentage()
|
||||
if progress == 0:
|
||||
return '未开始'
|
||||
|
||||
return current_state.name
|
||||
from stateflow.services import get_display_status
|
||||
return get_display_status(self.business_object)
|
||||
|
||||
@property
|
||||
def status_id(self):
|
||||
@@ -299,28 +287,16 @@ class PrintingJob(ModelBase):
|
||||
@property
|
||||
def status(self) -> str:
|
||||
"""
|
||||
返回当前状态名称(下一个待执行的状态名称)
|
||||
返回当前状态名称
|
||||
|
||||
规则:
|
||||
- current_state 为 None:返回"已完成"(没有待执行的节点)
|
||||
- current_state 不为 None + 进度 0%:返回"未开始"
|
||||
- current_state 不为 None + 进度 > 0%:返回 current_state.name(正在进行)
|
||||
- current_state 为 None:返回"已完成"
|
||||
- 否则:返回 current_state 的名称
|
||||
|
||||
注意:废除了"未开始"的概念,直接显示节点名称
|
||||
"""
|
||||
if not self.business_object:
|
||||
return '未开始'
|
||||
|
||||
current_state = self.business_object.get_current_state()
|
||||
|
||||
if current_state is None:
|
||||
# 没有待执行的节点,已完成
|
||||
return '已完成'
|
||||
|
||||
# 有待执行的节点,配合进度判断是"未开始"还是"进行中"
|
||||
progress = self.business_object.get_progress_percentage()
|
||||
if progress == 0:
|
||||
return '未开始'
|
||||
|
||||
return current_state.name
|
||||
from stateflow.services import get_display_status
|
||||
return get_display_status(self.business_object)
|
||||
|
||||
@property
|
||||
def status_id(self):
|
||||
|
||||
@@ -137,7 +137,7 @@ class PlateOrderModelTestCase(TestCase):
|
||||
customer=self.customer,
|
||||
)
|
||||
|
||||
self.assertEqual(plate_order.status, '未开始')
|
||||
self.assertEqual(plate_order.status, '') # 废除"未开始",显示空字符串
|
||||
self.assertFalse(plate_order.is_completed)
|
||||
self.assertFalse(plate_order.has_started) # 因为没有 business_object
|
||||
self.assertEqual(plate_order.progress_percentage, 0.0)
|
||||
|
||||
Reference in New Issue
Block a user