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

@@ -207,6 +207,49 @@ def modify_status(
return shipment
@transaction.atomic
def update_shipment(
shipment: Shipment,
*,
customer_id: int | None = None,
shipment_date=None,
area: str | None = None,
remark: str | None = None,
external_id: str | None = None,
) -> Shipment:
"""
更新出货单业务数据。
说明:
- 仅允许在草稿状态下修改
- 不处理状态变更
"""
from basic_info.models import Customer
if shipment.status != ShipmentStatus.DRAFT:
raise ValueError("仅草稿状态的出货单允许修改")
if customer_id is not None:
customer = Customer.objects.filter(id=customer_id).first()
if customer is None:
raise ValueError(f"客户 {customer_id} 不存在")
if customer.merchant_id != shipment.merchant_id:
raise ValueError("无权限绑定该客户")
shipment.customer = customer
if shipment_date is not None:
shipment.shipment_date = shipment_date
if area is not None:
shipment.area = (area or "").strip()
if remark is not None:
shipment.remark = remark or ""
if external_id is not None:
shipment.external_id = (external_id or "").strip() or None
shipment.save()
return shipment
@transaction.atomic
def create_shipment(
customer_id: int,