refector: 检验撤回的优化

This commit is contained in:
caoqianming 2024-04-23 09:13:21 +08:00
parent aecec48002
commit 22e5ff6180
1 changed files with 7 additions and 7 deletions

View File

@ -66,22 +66,22 @@ class InmService:
if not mioitems.exists():
raise ParseError("未填写物料明细")
type = instance.type
prodction_dept = instance.belong_dept
belong_dept = instance.belong_dept
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
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
out = -1
默认使用count字段做加减
"""
if type is None or production_dept is None:
if type is None or belong_dept is None:
mio = i.mio
type = mio.type
production_dept = mio.belong_dept
belong_dept = mio.belong_dept
material = i.material
warehouse = i.warehouse
mb, is_created = MaterialBatch.objects.get_or_create(
@ -90,8 +90,8 @@ class InmService:
if in_or_out == 1:
mb.count = mb.count + getattr(i, field)
if type == MIO.MIO_TYPE_DO_IN: # 生产入库需要记录production_dept字段
if mb.production_dept is None or mb.production_dept == production_dept:
mb.production_dept = production_dept
if mb.production_dept is None or mb.production_dept == belong_dept:
mb.production_dept = belong_dept
else:
raise ParseError("同种物料不同生产车间应该有不同批次号!")
mb.save()