From 16554c4f7765b8344de465053d7721161cd9add4 Mon Sep 17 00:00:00 2001 From: colaftc Date: Fri, 30 Jan 2026 20:28:02 +0800 Subject: [PATCH] fix: moved order_quantity to sales_order_item --- api_v1/views/business/sales/views.py | 4 ++-- business/admin.py | 2 +- .../0021_remove_salesorder_order_quantity.py | 22 +++++++++++++++++++ business/models.py | 2 +- 4 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 business/migrations/0021_remove_salesorder_order_quantity.py diff --git a/api_v1/views/business/sales/views.py b/api_v1/views/business/sales/views.py index 98d3f89..f2969b8 100644 --- a/api_v1/views/business/sales/views.py +++ b/api_v1/views/business/sales/views.py @@ -18,7 +18,7 @@ class SalesOrderItemSerializer(serializers.ModelSerializer): fields = [ 'id', 'product', 'price', 'color', 'quantity', 'unit', 'empty_diff_percent', 'quantity_of_rolls', 'num_of_rolls', - 'consume_detail_ids', 'batch_number', 'remarks', 'created_at', 'updated_at', 'spec', + 'consume_detail_ids', 'batch_number', 'order_quantity', 'remarks', 'created_at', 'updated_at', 'spec', ] read_only_fields = ['id', 'created_at', 'updated_at', 'total_amount', 'diff_quantity', 'real_quantity'] @@ -53,7 +53,7 @@ class SalesOrderSerializer(serializers.ModelSerializer): 'id', 'human_id', 'customer', 'customer_name', 'sales_date', 'kind', 'total_amount', 'diff_quantity', 'total_quantity', 'operator', 'operator_name', 'warehouse', 'warehouse_name', - 'status', 'order_quantity', 'remarks', 'created_at', 'updated_at', 'items', + 'status', 'remarks', 'created_at', 'updated_at', 'items', 'quantity_of_rolls', ] read_only_fields = ['id', 'created_at', 'updated_at', 'items', 'customer_name', 'operator_name', 'warehouse_name'] diff --git a/business/admin.py b/business/admin.py index c0e90d0..8ad4066 100644 --- a/business/admin.py +++ b/business/admin.py @@ -127,7 +127,7 @@ class SalesReturnOrderItemAdmin(admin.ModelAdmin): @admin.register(models.SalesOrder) class SalesOrderAdmin(admin.ModelAdmin): - list_display = ('id', 'human_id', 'customer', 'sales_date', 'operator', 'status', 'order_quantity', '_total_amount', '_diff_quantity', '_total_quantity', 'created_at') + list_display = ('id', 'human_id', 'customer', 'sales_date', 'operator', 'status', '_total_amount', '_diff_quantity', '_total_quantity', 'created_at') search_fields = ('customer__name',) list_filter = ('operator', 'warehouse', 'status', 'created_at') ordering = ('-created_at',) diff --git a/business/migrations/0021_remove_salesorder_order_quantity.py b/business/migrations/0021_remove_salesorder_order_quantity.py new file mode 100644 index 0000000..80690ba --- /dev/null +++ b/business/migrations/0021_remove_salesorder_order_quantity.py @@ -0,0 +1,22 @@ +# Generated by Django 5.2.7 on 2026-01-30 12:18 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('business', '0020_salesorder_order_quantity'), + ] + + operations = [ + migrations.RemoveField( + model_name='salesorder', + name='order_quantity', + ), + migrations.AddField( + model_name='salesorderitem', + name='order_quantity', + field=models.IntegerField(blank=True, null=True, verbose_name='下单数量'), + ), + ] diff --git a/business/models.py b/business/models.py index 4cca64a..66efcea 100644 --- a/business/models.py +++ b/business/models.py @@ -263,7 +263,6 @@ class SalesOrder(OrderItemsAggregationMixin, OrderDirectionMixin, OrderCounterpa default=SalesOrderStatusEnum.PENDING, verbose_name='状态', ) - order_quantity = models.IntegerField(null=True, blank=True, verbose_name='下单数量') remarks = models.TextField(blank=True, null=True, verbose_name='备注') def __str__(self): @@ -339,6 +338,7 @@ class SalesOrderItem(ModelBase): verbose_name='消耗入库明细ID列表', ) batch_number = models.CharField(null=True, blank=True, max_length=100, verbose_name='批次号') + order_quantity = models.IntegerField(null=True, blank=True, verbose_name='下单数量') remarks = models.TextField(blank=True, null=True, verbose_name='备注') class Meta: