diff --git a/apps/stock_in/models.py b/apps/stock_in/models.py index 661c0d3..ca08ac9 100644 --- a/apps/stock_in/models.py +++ b/apps/stock_in/models.py @@ -13,7 +13,8 @@ class StockInOrder(Model): STOCK_TRANSFER = ('stock_transfer', '调拨') number = CharField(max_length=32, verbose_name='编号') - warehouse = ForeignKey('data.Warehouse', on_delete=PROTECT, related_name='stock_in_orders', verbose_name='仓库') + warehouse = ForeignKey('data.Warehouse', on_delete=PROTECT, + related_name='stock_in_orders', verbose_name='仓库') type = CharField(max_length=32, choices=Type.choices, verbose_name='入库类型') purchase_order = OneToOneField('purchase.PurchaseOrder', on_delete=CASCADE, null=True, related_name='stock_in_order', verbose_name='采购单据') diff --git a/apps/stock_in/serializers.py b/apps/stock_in/serializers.py index 5dc08d7..4a58018 100644 --- a/apps/stock_in/serializers.py +++ b/apps/stock_in/serializers.py @@ -9,29 +9,34 @@ from apps.system.models import * class StockInOrderSerializer(BaseSerializer): """入库单据""" - class StockInGoodsSerializer(BaseSerializer): + class StockInGoodsItemSerializer(BaseSerializer): """入库商品""" goods_number = CharField(source='goods.number', read_only=True, label='商品编号') goods_name = CharField(source='goods.name', read_only=True, label='商品名称') goods_barcode = CharField(source='goods.barcode', read_only=True, label='商品条码') unit_name = CharField(source='goods.unit.name', read_only=True, label='单位名称') - enable_batch_control = BooleanField(source='goods.enable_batch_control', read_only=True, label='启用批次控制') + enable_batch_control = BooleanField(source='goods.enable_batch_control', + read_only=True, label='启用批次控制') shelf_life_days = CharField(source='goods.shelf_life_days', read_only=True, label='保质期天数') class Meta: model = StockInGoods - fields = ['id', 'goods', 'goods_number', 'goods_name', 'goods_barcode', 'stock_in_quantity', - 'remain_quantity', 'unit_name', 'enable_batch_control', 'shelf_life_days', 'is_completed'] + fields = ['id', 'goods', 'goods_number', 'goods_name', 'goods_barcode', + 'stock_in_quantity', 'remain_quantity', 'unit_name', 'enable_batch_control', + 'shelf_life_days', 'is_completed'] warehouse_number = CharField(source='warehouse.number', read_only=True, label='仓库编号') warehouse_name = CharField(source='warehouse.name', read_only=True, label='仓库名称') type_display = CharField(source='get_type_display', read_only=True, label='入库类型') purchase_order_number = CharField(source='purchase_order.number', read_only=True, label='采购单据编号') - sales_return_order_number = CharField(source='sales_return_order.number', read_only=True, label='销售退货单据编号') - stock_transfer_order_number = CharField(source='stock_transfer_order.number', read_only=True, label='调拨单据编号') + sales_return_order_number = CharField(source='sales_return_order.number', + read_only=True, label='销售退货单据编号') + stock_transfer_order_number = CharField(source='stock_transfer_order.number', + read_only=True, label='调拨单据编号') creator_name = CharField(source='creator.name', read_only=True, label='创建人名称') - stock_in_goods_items = StockInGoodsSerializer(source='stock_in_goods_set', many=True, label='入库商品') + stock_in_goods_items = StockInGoodsItemSerializer( + source='stock_in_goods_set', many=True, label='入库商品Item') class Meta: model = StockInOrder @@ -45,7 +50,7 @@ class StockInOrderSerializer(BaseSerializer): class StockInRecordSerializer(BaseSerializer): """入库记录""" - class StockInRecordGoodsSerializer(BaseSerializer): + class StockInRecordGoodsItemSerializer(BaseSerializer): """入库记录商品""" goods_number = CharField(source='goods.number', read_only=True, label='商品编号') @@ -58,7 +63,8 @@ class StockInRecordSerializer(BaseSerializer): model = StockInRecordGoods read_only_fields = ['id', 'goods', 'goods_number', 'goods_name', 'goods_barcode', 'unit_name', 'enable_batch_control', 'shelf_life_days', 'expiration_date'] - fields = ['stock_in_goods', 'stock_in_quantity', 'production_date', 'batch_number', *read_only_fields] + fields = ['stock_in_goods', 'stock_in_quantity', 'production_date', 'batch_number', + *read_only_fields] def validate_stock_in_goods(self, instance): instance = self.validate_foreign_key(StockInGoods, instance, message='入库商品不存在') @@ -91,8 +97,8 @@ class StockInRecordSerializer(BaseSerializer): warehouse_name = CharField(source='warehouse.name', read_only=True, label='仓库名称') handler_name = CharField(source='handler.name', read_only=True, label='经手人名称') creator_name = CharField(source='creator.name', read_only=True, label='创建人名称') - stock_in_record_goods_items = StockInRecordGoodsSerializer(source='stock_in_record_goods_set', - many=True, label='入库记录商品') + stock_in_record_goods_items = StockInRecordGoodsItemSerializer( + source='stock_in_record_goods_set', many=True, label='入库记录商品') class Meta: model = StockInRecord diff --git a/apps/stock_out/models.py b/apps/stock_out/models.py index 0a7fa66..ab0f65e 100644 --- a/apps/stock_out/models.py +++ b/apps/stock_out/models.py @@ -13,7 +13,8 @@ class StockOutOrder(Model): STOCK_TRANSFER = ('stock_transfer', '调拨') number = CharField(max_length=32, verbose_name='编号') - warehouse = ForeignKey('data.Warehouse', on_delete=PROTECT, related_name='stock_out_orders', verbose_name='仓库') + warehouse = ForeignKey('data.Warehouse', on_delete=PROTECT, + related_name='stock_out_orders', verbose_name='仓库') type = CharField(max_length=32, choices=Type.choices, verbose_name='出库类型') sales_order = OneToOneField('sales.SalesOrder', on_delete=CASCADE, null=True, related_name='stock_out_order', verbose_name='销售单据') @@ -52,7 +53,8 @@ class StockOutGoods(Model): stock_out_order = ForeignKey('stock_out.StockOutOrder', on_delete=CASCADE, related_name='stock_out_goods_set', verbose_name='出库单据') - goods = ForeignKey('goods.Goods', on_delete=PROTECT, related_name='stock_out_goods_set', verbose_name='商品') + goods = ForeignKey('goods.Goods', on_delete=PROTECT, + related_name='stock_out_goods_set', verbose_name='商品') stock_out_quantity = FloatField(verbose_name='出库总数') remain_quantity = FloatField(default=0, verbose_name='出库剩余数量') is_completed = BooleanField(default=False, verbose_name='完成状态') @@ -67,8 +69,10 @@ class StockOutRecord(Model): stock_out_order = ForeignKey('stock_out.StockOutOrder', on_delete=CASCADE, related_name='stock_out_records', verbose_name='出库单据') - warehouse = ForeignKey('data.Warehouse', on_delete=PROTECT, related_name='stock_out_records', verbose_name='仓库') - handler = ForeignKey('system.User', on_delete=PROTECT, related_name='stock_out_records', verbose_name='经手人') + warehouse = ForeignKey('data.Warehouse', on_delete=PROTECT, + related_name='stock_out_records', verbose_name='仓库') + handler = ForeignKey('system.User', on_delete=PROTECT, + related_name='stock_out_records', verbose_name='经手人') handle_time = DateTimeField(verbose_name='处理时间') remark = CharField(max_length=256, null=True, blank=True, verbose_name='备注') total_quantity = FloatField(null=True, verbose_name='出库总数') @@ -86,7 +90,8 @@ class StockOutRecordGoods(Model): related_name='stock_out_record_goods_set', verbose_name='出库记录') stock_out_goods = ForeignKey('stock_out.StockOutGoods', on_delete=CASCADE, related_name='stock_out_record_goods_set', verbose_name='出库商品') - goods = ForeignKey('goods.Goods', on_delete=PROTECT, related_name='stock_out_record_goods_set', verbose_name='商品') + goods = ForeignKey('goods.Goods', on_delete=PROTECT, + related_name='stock_out_record_goods_set', verbose_name='商品') stock_out_quantity = FloatField(verbose_name='出库数量') enable_batch_control = BooleanField(default=False, verbose_name='启用批次控制') batch = OneToOneField('goods.Batch', on_delete=CASCADE, null=True, diff --git a/apps/stock_out/serializers.py b/apps/stock_out/serializers.py index de69d30..4f32d78 100644 --- a/apps/stock_out/serializers.py +++ b/apps/stock_out/serializers.py @@ -9,14 +9,15 @@ from apps.system.models import * class StockOutOrderSerializer(BaseSerializer): """出库单据""" - class StockOutGoodsSerializer(BaseSerializer): + class StockOutGoodsItemSerializer(BaseSerializer): """出库商品""" goods_number = CharField(source='goods.number', read_only=True, label='商品编号') goods_name = CharField(source='goods.name', read_only=True, label='商品名称') goods_barcode = CharField(source='goods.barcode', read_only=True, label='商品条码') unit_name = CharField(source='goods.unit.name', read_only=True, label='单位名称') - enable_batch_control = BooleanField(source='goods.enable_batch_control', read_only=True, label='启用批次控制') + enable_batch_control = BooleanField(source='goods.enable_batch_control', + read_only=True, label='启用批次控制') class Meta: model = StockOutGoods @@ -27,10 +28,13 @@ class StockOutOrderSerializer(BaseSerializer): warehouse_name = CharField(source='warehouse.name', read_only=True, label='仓库名称') type_display = CharField(source='get_type_display', read_only=True, label='出库类型') sales_order_number = CharField(source='sales_order.number', read_only=True, label='销售单据编号') - purchase_return_order_number = CharField(source='purchase_return_order.number', read_only=True, label='采购退货单据编号') - stock_transfer_order_number = CharField(source='stock_transfer_order.number', read_only=True, label='调拨单据编号') + purchase_return_order_number = CharField(source='purchase_return_order.number', + read_only=True, label='采购退货单据编号') + stock_transfer_order_number = CharField(source='stock_transfer_order.number', + read_only=True, label='调拨单据编号') creator_name = CharField(source='creator.name', read_only=True, label='创建人名称') - stock_out_goods_items = StockOutGoodsSerializer(source='stock_out_goods_set', many=True, label='出库商品') + stock_out_goods_items = StockOutGoodsItemSerializer( + source='stock_out_goods_set', many=True, label='出库商品') class Meta: model = StockOutOrder diff --git a/documents/项目文档/库内管理/入库任务.md b/documents/项目文档/库内管理/入库任务.md index 6393807..20a51dd 100644 --- a/documents/项目文档/库内管理/入库任务.md +++ b/documents/项目文档/库内管理/入库任务.md @@ -3,5 +3,14 @@ ## 功能 +- 查询入库单: +[/api/stock_in_orders/] + +- 查询/创建入库记录: +[/api/stock_in_records/] + +- 作废入库记录: +[/api/stock_in_records/{id}/void/] + ## 其他接口 diff --git a/documents/项目文档/库内管理/出库任务.md b/documents/项目文档/库内管理/出库任务.md index b018082..9a05d1e 100644 --- a/documents/项目文档/库内管理/出库任务.md +++ b/documents/项目文档/库内管理/出库任务.md @@ -3,5 +3,17 @@ ## 功能 +- 查询出库单: +[/api/stock_out_orders/] + +- 查询/创建出库记录: +[/api/stock_out_records/] + +- 作废出库记录: +[/api/stock_out_records/{id}/void/] + ## 其他接口 + +- 批次选项: +[/api/batchs/options/]{page, warehouse, goods, has_stock: true}