1
0
forked from erp-dev/erp

feat: improve for report

This commit is contained in:
2026-01-16 17:25:21 +08:00
parent 0c24c7e7e9
commit 2e0b7dc335
6 changed files with 417 additions and 73 deletions

View File

@@ -241,6 +241,56 @@ class BusinessObjectCRUDAndFilterAPITestCase(TestCase):
self.assertEqual(resp.status_code, status.HTTP_200_OK)
self.assertEqual(resp.data["count"], 0)
def test_business_object_filters_by_completed_state_and_param(self):
"""
新增能力:按“已完成的 state_id + 工艺参数 key/value”反查 BusinessObject 列表
语义确认:
- “处于某状态”指已完成该状态节点(存在 StateFlowRecord 且 is_cancelled=False
- 参数匹配绑定在同一个 state_log 下的 StateLogParameterRecord.parameters
"""
ct = self.user_content_type
bo_match = models.BusinessObject.objects.create(
name="BO-Match",
process=self.process_a,
content_type=ct,
object_id=self.user.id,
)
services.advance_to_next_state(bo_match, self.user, **{"设计师名称": "AAA"})
bo_other_value = models.BusinessObject.objects.create(
name="BO-OtherValue",
process=self.process_a,
content_type=ct,
object_id=self.user.id,
)
services.advance_to_next_state(bo_other_value, self.user, **{"设计师名称": "BBB"})
bo_cancelled = models.BusinessObject.objects.create(
name="BO-Cancelled",
process=self.process_a,
content_type=ct,
object_id=self.user.id,
)
services.advance_to_next_state(bo_cancelled, self.user, **{"设计师名称": "AAA"})
services.step_back_one_state(bo_cancelled, self.user)
resp = self.client.get(
"/api/v1/stateflow/business-objects/",
data={
"content_type_str": "auth.user",
"state_id": self.state1.id,
"param_key": "设计师名称",
"param_value": "AAA",
"limit": 50,
"offset": 0,
},
)
self.assertEqual(resp.status_code, status.HTTP_200_OK)
returned_ids = {x["id"] for x in resp.data["results"]}
self.assertSetEqual(returned_ids, {bo_match.id})
class AuthenticationGuardAPITestCase(TestCase):
def test_stateflow_endpoints_require_authentication(self):