From 3412937bcb06ad9f1a21ee3ea95e528fb0999548 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Fri, 25 Feb 2022 16:00:38 +0800 Subject: [PATCH 1/2] =?UTF-8?q?inm=20=E5=85=A5=E5=BA=93bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hb_server/apps/inm/services.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/hb_server/apps/inm/services.py b/hb_server/apps/inm/services.py index c9fbbeb..8be61b7 100644 --- a/hb_server/apps/inm/services.py +++ b/hb_server/apps/inm/services.py @@ -25,10 +25,11 @@ class InmService: iv, _= Inventory.objects.get_or_create(material=material, warehouse=warehouse, \ defaults={'material':material, 'warehouse':warehouse, 'count':0}) - iv.count = MaterialBatch.objects.filter(material=material, warehouse=warehouse).count() + iv.count = MaterialBatch.objects.filter(material=material, + warehouse=warehouse).aggregate(total=Sum('count')).get('total', 0) iv.save() - material.count = MaterialBatch.objects.filter(material=material).count() + material.count = MaterialBatch.objects.filter(material=material).aggregate(total=Sum('count')).get('total', 0) material.save() # 创建IProduct @@ -66,10 +67,12 @@ class InmService: mb.save() iv = Inventory.objects.get(material=material, warehouse=warehouse) - iv.count = MaterialBatch.objects.filter(material=material, warehouse=warehouse).count() + iv.count = MaterialBatch.objects.filter(material=material, + warehouse=warehouse).aggregate(total=Sum('count')).get('total', 0) iv.save() - material.count = MaterialBatch.objects.filter(material=material).count() + material.count = MaterialBatch.objects.filter(material= + material).aggregate(total=Sum('count')).get('total', 0) material.save() # 删除IProduct From ad85757504f4ab4701f74d4e6489681ec5f849f8 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Fri, 25 Feb 2022 16:02:55 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E9=87=87=E8=B4=AD=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E6=9C=AA=E5=AE=A1=E6=A0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hb_server/apps/inm/serializers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hb_server/apps/inm/serializers.py b/hb_server/apps/inm/serializers.py index 6f29ac2..d033aaa 100644 --- a/hb_server/apps/inm/serializers.py +++ b/hb_server/apps/inm/serializers.py @@ -192,7 +192,7 @@ class FIFOInPurSerializer(serializers.ModelSerializer): def create(self, validated_data): pu_order = validated_data['pu_order'] - if pu_order.is_audited: + if not pu_order.is_audited: raise ValidationError('该采购订单未审核') validated_data['vendor'] = pu_order.vendor validated_data['number'] = 'RK' + ranstr(7)