fix: BatchLog创建时获取source再创建target
This commit is contained in:
parent
6b7088997f
commit
0735b5d2b7
|
@ -177,12 +177,12 @@ def mlog_submit(mlog: Mlog, user: User, now: Union[datetime.datetime, None]):
|
|||
m_outs = Mlogb.objects.filter(mlog=mlog, material_out__isnull=False)
|
||||
for item in m_outs:
|
||||
if item.mlogb_from and item.batch != item.mlogb_from.batch:
|
||||
target, _ = BatchSt.g_create(batch=item.batch, mlog=mlog, material_start=item.material_out)
|
||||
source, _ = BatchSt.g_create(batch=item.mlogb_from.batch)
|
||||
target, _ = BatchSt.g_create(batch=item.batch, mlog=mlog, material_start=item.material_out)
|
||||
BatchLog.g_create(source= source, target=target, mlog=mlog)
|
||||
if item.mlogbw_from and item.batch != item.mlogbw_from.mlogb.batch:
|
||||
target, _ = BatchSt.g_create(batch=item.batch, mlog=mlog, material_start=item.material_out)
|
||||
source, _ = BatchSt.g_create(batch=item.mlogbw_from.mlogb.batch)
|
||||
target, _ = BatchSt.g_create(batch=item.batch, mlog=mlog, material_start=item.material_out)
|
||||
BatchLog.g_create(source=source, target=target, mlog=mlog)
|
||||
|
||||
if material_in or is_fix: # 需要进行车间库存管理
|
||||
|
@ -756,17 +756,17 @@ def handover_submit(handover:Handover, user: User, now: Union[datetime.datetime,
|
|||
|
||||
# 合并为新批
|
||||
if mtype == Handover.H_MERGE:
|
||||
source, _ = BatchSt.g_create(batch=wm_from.batch)
|
||||
batch = new_batch
|
||||
if new_target is None:
|
||||
new_target, _ = BatchSt.g_create(batch=batch, handover=handover, material_start=material)
|
||||
source, _ = BatchSt.g_create(batch=wm_from.batch)
|
||||
BatchLog.g_create(source=source, target=new_target, handover=handover, relation_type="merge")
|
||||
elif mtype == Handover.H_DIV:
|
||||
batch = handover_or_b.batch
|
||||
target, _ = BatchSt.g_create(batch=batch, handover=handover, material_start=material)
|
||||
if handover.wm is None:
|
||||
raise ParseError('拆批请选择车间库存')
|
||||
source, _ = BatchSt.g_create(batch=handover.wm.batch)
|
||||
batch = handover_or_b.batch
|
||||
target, _ = BatchSt.g_create(batch=batch, handover=handover, material_start=material)
|
||||
BatchLog.g_create(source=source, target=target, handover=handover, relation_type="split")
|
||||
else:
|
||||
batch = wm_from.batch
|
||||
|
|
Loading…
Reference in New Issue