1
0
forked from erp-dev/erp

fix: 出货单审核后也可以修改了(未绑定送货单都可以)

This commit is contained in:
2026-04-22 15:36:14 +08:00
parent 35e6af1128
commit 35a03218d8
3 changed files with 36 additions and 9 deletions

View File

@@ -1876,9 +1876,9 @@ class ShipmentQueryAPITestCase(TestCase):
self.assertEqual(self.shipment1.contact_name, "王五")
self.assertEqual(self.shipment1.contact_phone, "13700137000")
def test_patch_shipment_rejects_non_draft(self):
def test_patch_shipment_allows_approved_shipment_without_delivery(self):
"""
非草稿状态的出货单允许修改业务数据。
已审核但未关联送货单的出货单允许修改业务数据。
"""
from shipment.services import modify_status
@@ -1887,6 +1887,33 @@ class ShipmentQueryAPITestCase(TestCase):
target_status=shipment_models.ShipmentStatus.PUBLISHED,
operator=self.user1,
)
modify_status(
self.shipment1,
target_status=shipment_models.ShipmentStatus.APPROVED,
operator=self.user1,
approved_by=self.user1,
)
resp = self.client.patch(
f"/api/v1/shipment/shipments/{self.shipment1.id}/",
data={"area": "审核后可修改"},
format="json",
)
self.assertEqual(resp.status_code, status.HTTP_200_OK)
self.assertEqual(resp.json()["area"], "审核后可修改")
self.shipment1.refresh_from_db()
self.assertEqual(self.shipment1.area, "审核后可修改")
def test_patch_shipment_rejects_when_bound_to_delivery(self):
delivery = shipment_models.ShipmentDelivery.objects.create(
merchant=self.merchant1,
driver_name="绑定司机",
vehicle_trip="LOCK-001",
created_by=self.user1,
)
self.shipment1.delivery = delivery
self.shipment1.save(update_fields=["delivery", "updated_at"])
resp = self.client.patch(
f"/api/v1/shipment/shipments/{self.shipment1.id}/",
@@ -1894,7 +1921,7 @@ class ShipmentQueryAPITestCase(TestCase):
format="json",
)
self.assertEqual(resp.status_code, status.HTTP_400_BAD_REQUEST)
self.assertIn("仅草稿状态", resp.json()["detail"])
self.assertIn("已关联送货单", resp.json()["detail"])
self.shipment1.refresh_from_db()
self.assertEqual(self.shipment1.area, "A1")