refector: 检验撤回的优化
This commit is contained in:
parent
aecec48002
commit
22e5ff6180
|
@ -66,22 +66,22 @@ class InmService:
|
||||||
if not mioitems.exists():
|
if not mioitems.exists():
|
||||||
raise ParseError("未填写物料明细")
|
raise ParseError("未填写物料明细")
|
||||||
type = instance.type
|
type = instance.type
|
||||||
prodction_dept = instance.belong_dept
|
belong_dept = instance.belong_dept
|
||||||
for i in MIOItem.objects.filter(mio=instance):
|
for i in MIOItem.objects.filter(mio=instance):
|
||||||
cls.update_mb_item(i, in_or_out, type, prodction_dept)
|
cls.update_mb_item(i, in_or_out, 'count', type, belong_dept)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def update_mb_item(cls, i: MIOItem, in_or_out: int = 1, field:str='count', type: str =None, production_dept: Dept=None):
|
def update_mb_item(cls, i: MIOItem, in_or_out: int = 1, field:str='count', type: str =None, belong_dept: Dept=None):
|
||||||
"""
|
"""
|
||||||
更新物料批次(根据明细)
|
更新物料批次(根据明细)
|
||||||
in = 1
|
in = 1
|
||||||
out = -1
|
out = -1
|
||||||
默认使用count字段做加减
|
默认使用count字段做加减
|
||||||
"""
|
"""
|
||||||
if type is None or production_dept is None:
|
if type is None or belong_dept is None:
|
||||||
mio = i.mio
|
mio = i.mio
|
||||||
type = mio.type
|
type = mio.type
|
||||||
production_dept = mio.belong_dept
|
belong_dept = mio.belong_dept
|
||||||
material = i.material
|
material = i.material
|
||||||
warehouse = i.warehouse
|
warehouse = i.warehouse
|
||||||
mb, is_created = MaterialBatch.objects.get_or_create(
|
mb, is_created = MaterialBatch.objects.get_or_create(
|
||||||
|
@ -90,8 +90,8 @@ class InmService:
|
||||||
if in_or_out == 1:
|
if in_or_out == 1:
|
||||||
mb.count = mb.count + getattr(i, field)
|
mb.count = mb.count + getattr(i, field)
|
||||||
if type == MIO.MIO_TYPE_DO_IN: # 生产入库需要记录production_dept字段
|
if type == MIO.MIO_TYPE_DO_IN: # 生产入库需要记录production_dept字段
|
||||||
if mb.production_dept is None or mb.production_dept == production_dept:
|
if mb.production_dept is None or mb.production_dept == belong_dept:
|
||||||
mb.production_dept = production_dept
|
mb.production_dept = belong_dept
|
||||||
else:
|
else:
|
||||||
raise ParseError("同种物料不同生产车间应该有不同批次号!")
|
raise ParseError("同种物料不同生产车间应该有不同批次号!")
|
||||||
mb.save()
|
mb.save()
|
||||||
|
|
Loading…
Reference in New Issue