From e92ceca953eef82bd106e38fb31ff5f8bd82fcb7 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Thu, 14 Nov 2024 10:52:21 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20MaterialBatch=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E4=BB=A5=E6=94=AF=E6=8C=81=E8=BF=BD=E8=B8=AA?= =?UTF-8?q?=E5=8E=9F=E6=96=99=E6=89=B9=E6=AC=A15?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/inm/services.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/apps/inm/services.py b/apps/inm/services.py index f01a31d8..28489fbc 100644 --- a/apps/inm/services.py +++ b/apps/inm/services.py @@ -113,6 +113,7 @@ def do_in(item: MIOItem): else: action_list = [[item.material, item.batch, item.count]] + production_dept = None for al in action_list: xmaterial, xbatch, xcount = al @@ -140,13 +141,22 @@ def do_in(item: MIOItem): else: raise ParseError(f'{str(xmaterial)}-{xbatch}车间物料不足') + if production_dept is None: + production_dept = wm.mgroup.belong_dept + elif production_dept != wm.mgroup.belong_dept: + raise ParseError(f'{str(xmaterial)}-{xbatch}车间物料不属于同一车间') # 增加mb if not is_zhj: mb, _ = MaterialBatch.objects.get( material=xmaterial, warehouse=item.warehouse, batch=xbatch, - defaults={"count": 0, "batch_ofrom": wm.batch_ofrom, "material_ofrom": xmaterial} + defaults={ + "count": 0, + "batch_ofrom": wm.batch_ofrom, + "material_ofrom": xmaterial, + "production_dept": production_dept + } ) mb.count = mb.count + xcount mb.save() @@ -157,7 +167,7 @@ def do_in(item: MIOItem): material=item.material, warehouse=item.warehouse, batch=item.batch, - defaults={"count": 0} + defaults={"count": 0, "production_dept": production_dept} ) if not is_created: raise ParseError("该批次组合件已存在")