1
0
forked from erp-dev/erp

feat: printing orders and jobs filter with external_order_id

This commit is contained in:
2026-03-20 22:36:31 +08:00
parent fa9721762c
commit b58667ca52
5 changed files with 142 additions and 7 deletions

View File

@@ -73,6 +73,7 @@ class HasActivatePrintingOrderPermission(BasePermission):
class PrintingOrderFilterSet(django_filters.FilterSet):
"""印染订单过滤器"""
external_order_id = django_filters.CharFilter(lookup_expr='icontains')
customer_name = django_filters.CharFilter(field_name='customer__name', lookup_expr='icontains')
customer_phone = django_filters.CharFilter(field_name='customer__phone', lookup_expr='icontains')
fabric = django_filters.CharFilter(lookup_expr='icontains')
@@ -87,7 +88,7 @@ class PrintingOrderFilterSet(django_filters.FilterSet):
class Meta:
model = models.PrintingOrder
fields = ['customer', 'is_urgent', 'is_fabric_received', 'is_invalid']
fields = ['customer', 'is_urgent', 'is_fabric_received', 'is_invalid', 'external_order_id']
@staticmethod
def _parse_date_or_datetime(value: str | None) -> tuple[datetime | None, bool]:
@@ -168,6 +169,7 @@ class PrintingOrderViewSet(CustomerVisibilityFilterMixin, LimitedModelViewSet):
查询参数:
- customer: 客户ID
- external_order_id: 外部订单编号(模糊查询)
- customer_name: 客户名称(模糊查询)
- customer_phone: 客户电话(模糊查询)
- fabric: 面料(模糊查询)
@@ -343,6 +345,7 @@ class PrintingOrderViewSet(CustomerVisibilityFilterMixin, LimitedModelViewSet):
class PrintingJobFilterSet(django_filters.FilterSet):
"""印染款式明细过滤器"""
printing_order = django_filters.NumberFilter()
external_order_id = django_filters.CharFilter(field_name='printing_order__external_order_id', lookup_expr='icontains')
product = django_filters.NumberFilter()
product_name = django_filters.CharFilter(field_name='product__name', lookup_expr='icontains')
unit = django_filters.CharFilter(lookup_expr='icontains')
@@ -353,7 +356,7 @@ class PrintingJobFilterSet(django_filters.FilterSet):
class Meta:
model = models.PrintingJob
fields = ['printing_order', 'product']
fields = ['printing_order', 'product', 'external_order_id']
class PrintingJobViewSet(CustomerVisibilityFilterMixin, LimitedModelViewSet):
@@ -379,6 +382,7 @@ class PrintingJobViewSet(CustomerVisibilityFilterMixin, LimitedModelViewSet):
查询参数:
- printing_order: 印染订单ID
- external_order_id: 外部订单编号(按所属订单模糊查询)
- product: 产品ID
- product_name: 产品名称(模糊查询)
- unit: 单位(模糊查询)