fix: handover_submit针对混料特殊处理的bug
This commit is contained in:
parent
b429ad9059
commit
3ddb050330
|
@ -281,26 +281,31 @@ def handover_submit(handover: Handover, user: User, now: Union[datetime.datetime
|
||||||
if handover.submit_time is not None:
|
if handover.submit_time is not None:
|
||||||
return
|
return
|
||||||
now = timezone.now()
|
now = timezone.now()
|
||||||
if handover.wm:
|
need_add = True
|
||||||
wm: WMaterial = handover.wm
|
material = handover.material
|
||||||
need_add = True
|
batch = handover.batch
|
||||||
if '混料' in wm.material.name: # hard code
|
try:
|
||||||
need_add = False
|
wm_from = WMaterial.objects.get(
|
||||||
count_x = wm.count - handover.count
|
material=material, batch=batch, belong_dept=handover.send_dept)
|
||||||
if count_x < 0:
|
except Exception as e:
|
||||||
raise ParseError('车间库存不足!')
|
raise ParseError(f'找不到车间库存:{e}')
|
||||||
elif count_x == 0:
|
if '混料' in material.name: # hard code
|
||||||
wm.delete()
|
need_add = False
|
||||||
else:
|
count_x = wm_from.count - handover.count
|
||||||
wm.count = count_x
|
if count_x < 0:
|
||||||
wm.save()
|
raise ParseError('车间库存不足!')
|
||||||
if need_add:
|
elif count_x == 0:
|
||||||
wm_to, _ = WMaterial.objects.get_or_create(batch=handover.batch, material=handover.material, belong_dept=handover.send_dept, defaults={
|
wm_from.delete()
|
||||||
'batch': handover.batch, 'material': handover.material, 'belong_dept': handover.send_dept
|
else:
|
||||||
})
|
wm_from.count = count_x
|
||||||
wm_to.count = wm_to.count + handover.count
|
wm_from.save()
|
||||||
wm_to.count_eweight = handover.count_eweight
|
if need_add:
|
||||||
wm_to.save()
|
wm_to, _ = WMaterial.objects.get_or_create(batch=handover.batch, material=handover.material, belong_dept=handover.send_dept, defaults={
|
||||||
|
'batch': handover.batch, 'material': handover.material, 'belong_dept': handover.send_dept
|
||||||
|
})
|
||||||
|
wm_to.count = wm_to.count + handover.count
|
||||||
|
wm_to.count_eweight = handover.count_eweight
|
||||||
|
wm_to.save()
|
||||||
handover.submit_user = user
|
handover.submit_user = user
|
||||||
handover.submit_time = now
|
handover.submit_time = now
|
||||||
handover.save()
|
handover.save()
|
||||||
|
|
Loading…
Reference in New Issue