1
0
forked from erp-dev/erp

feat: field pre_purchase_order_id for purchase_order (allow null)

This commit is contained in:
2026-02-04 20:14:59 +08:00
parent 02f6de3a8a
commit a8c61667a9
6 changed files with 74 additions and 11 deletions

View File

@@ -95,6 +95,7 @@ class PurchaseOrderView(StockChangeViewMixin, views.APIView):
order_date = data.get('order_date')
items = data.get('items', [])
remarks = data.get('remarks', '')
from_pre_purchase_order_id = data.get('from_pre_purchase_order_id')
if not supplier_id:
return Response({'error': '缺少供应商 ID'}, status=status.HTTP_400_BAD_REQUEST)
@@ -126,6 +127,7 @@ class PurchaseOrderView(StockChangeViewMixin, views.APIView):
operator=operator,
items=items,
remarks=remarks,
from_pre_purchase_order_id=from_pre_purchase_order_id,
created_by=request.user,
)
except ValueError as exc:
@@ -192,6 +194,7 @@ class PurchaseOrderDetailView(StockChangeViewMixin, views.APIView):
if not isinstance(items, list) or not items:
return Response({'error': 'items 需要为非空数组'}, status=status.HTTP_400_BAD_REQUEST)
remarks = data.get('remarks', purchase_order.remarks)
from_pre_purchase_order_id = data.get('from_pre_purchase_order_id')
try:
updated_order = business_services.update_purchase_order(
@@ -201,6 +204,7 @@ class PurchaseOrderDetailView(StockChangeViewMixin, views.APIView):
warehouse=warehouse,
items=items,
remarks=remarks,
from_pre_purchase_order_id=from_pre_purchase_order_id,
)
except ValueError as exc:
return Response({'error': str(exc)}, status=status.HTTP_400_BAD_REQUEST)