1
0
forked from erp-dev/erp

fix: DISABLE_SERVER_SIDE_CURSORS

This commit is contained in:
2026-04-02 19:13:35 +08:00
parent 1be840a8c2
commit 371cd796e7
5 changed files with 111 additions and 25 deletions

View File

@@ -239,33 +239,20 @@ class ShipmentDetailView(RetrieveModelMixin, GenericAPIView):
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
data = serializer.validated_data
# customer 变更需校验 merchant 一致
if "customer" in data:
from basic_info.models import Customer
from shipment.services import update_shipment
try:
customer = Customer.objects.get(id=data["customer"])
except Customer.DoesNotExist:
return Response(
{"detail": f"客户 {data['customer']} 不存在"},
status=status.HTTP_400_BAD_REQUEST,
)
if customer.merchant_id != shipment.merchant_id:
return Response(
{"detail": "无权限绑定该客户"}, status=status.HTTP_400_BAD_REQUEST
)
shipment.customer = customer
try:
shipment = update_shipment(
shipment,
customer_id=data.get("customer"),
shipment_date=data.get("shipment_date"),
area=data.get("area"),
remark=data.get("remark"),
external_id=data.get("external_id"),
)
except ValueError as e:
return Response({"detail": str(e)}, status=status.HTTP_400_BAD_REQUEST)
if "shipment_date" in data:
shipment.shipment_date = data["shipment_date"]
if "area" in data:
shipment.area = (data.get("area") or "").strip()
if "remark" in data:
shipment.remark = data.get("remark") or ""
if "external_id" in data:
shipment.external_id = (data.get("external_id") or "").strip() or None
shipment.save()
return Response(ShipmentSerializer(shipment).data, status=status.HTTP_200_OK)
def put(self, request, pk: int):