Compare commits
No commits in common. "08d9b7c7a7f607d17d1b177faadc8eedeca2a6f6" and "5354557f4ac8a5b7ea03be506b80cdde2cda9cc8" have entirely different histories.
08d9b7c7a7
...
5354557f4a
|
|
@ -13,6 +13,9 @@ def do_out(item: MIOItem, is_reverse: bool = False):
|
||||||
"""
|
"""
|
||||||
生产领料到车间
|
生产领料到车间
|
||||||
"""
|
"""
|
||||||
|
if item.mb and item.mb.defect is not None:
|
||||||
|
raise ParseError("生产领料不支持不合格品")
|
||||||
|
|
||||||
from apps.inm.models import MaterialBatch
|
from apps.inm.models import MaterialBatch
|
||||||
mio:MIO = item.mio
|
mio:MIO = item.mio
|
||||||
belong_dept = mio.belong_dept
|
belong_dept = mio.belong_dept
|
||||||
|
|
@ -72,10 +75,6 @@ def do_out(item: MIOItem, is_reverse: bool = False):
|
||||||
xcount:str = al[2]
|
xcount:str = al[2]
|
||||||
defect:Defect = al[3]
|
defect:Defect = al[3]
|
||||||
|
|
||||||
state = WMaterial.WM_OK
|
|
||||||
if defect and defect.okcate in [Defect.DEFECT_NOTOK]:
|
|
||||||
state = WMaterial.WM_NOTOK
|
|
||||||
|
|
||||||
xbatches.append(xbatch)
|
xbatches.append(xbatch)
|
||||||
if xcount <= 0:
|
if xcount <= 0:
|
||||||
raise ParseError("存在非正数!")
|
raise ParseError("存在非正数!")
|
||||||
|
|
@ -83,13 +82,13 @@ def do_out(item: MIOItem, is_reverse: bool = False):
|
||||||
if not is_zhj:
|
if not is_zhj:
|
||||||
try:
|
try:
|
||||||
mb = MaterialBatch.objects.get(
|
mb = MaterialBatch.objects.get(
|
||||||
material=xmaterial,
|
material=xmaterial,
|
||||||
warehouse=item.warehouse,
|
warehouse=item.warehouse,
|
||||||
batch=xbatch,
|
batch=xbatch,
|
||||||
state=state,
|
state=WMaterial.WM_OK,
|
||||||
defect=defect
|
defect=defect
|
||||||
)
|
)
|
||||||
except (MaterialBatch.DoesNotExist, MaterialBatch.MultipleObjectsReturned) as e:
|
except (MaterialBatch.DoesNotExist, MaterialBatch.MultipleObjectsReturned) as e:
|
||||||
raise ParseError(f"{str(xmaterial)}批次{xbatch}错误!{e}")
|
raise ParseError(f"{str(xmaterial)}批次{xbatch}错误!{e}")
|
||||||
mb.count = mb.count - xcount
|
mb.count = mb.count - xcount
|
||||||
if mb.count < 0:
|
if mb.count < 0:
|
||||||
|
|
@ -101,8 +100,8 @@ def do_out(item: MIOItem, is_reverse: bool = False):
|
||||||
# 领到车间库存(或工段)
|
# 领到车间库存(或工段)
|
||||||
wm, new_create = WMaterial.objects.get_or_create(
|
wm, new_create = WMaterial.objects.get_or_create(
|
||||||
batch=xbatch, material=xmaterial,
|
batch=xbatch, material=xmaterial,
|
||||||
belong_dept=belong_dept, mgroup=mgroup,
|
belong_dept=belong_dept, mgroup=mgroup,
|
||||||
state=state, defect=defect)
|
state=WMaterial.WM_OK, defect=defect)
|
||||||
if new_create:
|
if new_create:
|
||||||
wm.create_by = do_user
|
wm.create_by = do_user
|
||||||
wm.batch_ofrom = mb.batch if mb else None
|
wm.batch_ofrom = mb.batch if mb else None
|
||||||
|
|
@ -176,23 +175,19 @@ def do_in(item: MIOItem):
|
||||||
xmaterial, xbatch, xcount, defect, xwm = al
|
xmaterial, xbatch, xcount, defect, xwm = al
|
||||||
if xcount <= 0:
|
if xcount <= 0:
|
||||||
raise ParseError("存在非正数!")
|
raise ParseError("存在非正数!")
|
||||||
|
|
||||||
state = WMaterial.WM_OK
|
|
||||||
if defect and defect.okcate in [Defect.DEFECT_NOTOK]:
|
|
||||||
state = WMaterial.WM_NOTOK
|
|
||||||
|
|
||||||
xbatchs.append(xbatch)
|
xbatchs.append(xbatch)
|
||||||
if xmaterial.into_wm:
|
if xmaterial.into_wm:
|
||||||
if xwm:
|
if xwm:
|
||||||
wm = xwm
|
wm = xwm
|
||||||
else:
|
else:
|
||||||
wm_qs = WMaterial.objects.filter(
|
wm_qs = WMaterial.objects.filter(
|
||||||
batch=xbatch,
|
batch=xbatch,
|
||||||
material=xmaterial,
|
material=xmaterial,
|
||||||
belong_dept=belong_dept,
|
belong_dept=belong_dept,
|
||||||
mgroup=mgroup,
|
mgroup=mgroup,
|
||||||
defect=defect,
|
defect=defect,
|
||||||
state=state)
|
state=WMaterial.WM_OK)
|
||||||
count_x = wm_qs.count()
|
count_x = wm_qs.count()
|
||||||
if count_x == 1:
|
if count_x == 1:
|
||||||
wm = wm_qs.first()
|
wm = wm_qs.first()
|
||||||
|
|
@ -221,10 +216,10 @@ def do_in(item: MIOItem):
|
||||||
# 增加mb
|
# 增加mb
|
||||||
if not is_zhj:
|
if not is_zhj:
|
||||||
mb, _ = MaterialBatch.objects.get_or_create(
|
mb, _ = MaterialBatch.objects.get_or_create(
|
||||||
material=xmaterial,
|
material=xmaterial,
|
||||||
warehouse=item.warehouse,
|
warehouse=item.warehouse,
|
||||||
batch=xbatch,
|
batch=xbatch,
|
||||||
state=state,
|
state=WMaterial.WM_OK,
|
||||||
defect=defect,
|
defect=defect,
|
||||||
defaults={
|
defaults={
|
||||||
"count": 0,
|
"count": 0,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue