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("该批次组合件已存在")