feat: 有mloga之后的对应mlog_confirm修改
This commit is contained in:
parent
732a33f1f2
commit
6f825546ac
|
@ -11,7 +11,7 @@ from apps.inm.models import MIO, MIOItem, MIOItemA
|
|||
from apps.pm.models import Mtask
|
||||
from apps.mtm.models import Mgroup, Shift, Material
|
||||
|
||||
from .models import SfLog, SfLogExp, WMaterial, Mlog
|
||||
from .models import SfLog, SfLogExp, WMaterial, Mlog, Mlogb
|
||||
|
||||
|
||||
def make_sflogs(mgroup: Mgroup, start_date: datetime.date, end_date: datetime.date):
|
||||
|
@ -140,12 +140,20 @@ def mlog_confirm(mlog: Mlog):
|
|||
else:
|
||||
material_has.count = material_has.count - mlog.count_use
|
||||
material_has.save()
|
||||
if material_out.is_hidden is False: # 需要入库
|
||||
wmaterial, _ = WMaterial.objects.get_or_create(batch=mlog.batch, material=material_out, belong_dept=belong_dept, defaults={
|
||||
'batch': mlog.batch, 'material': material_out, 'belong_dept': belong_dept
|
||||
})
|
||||
wmaterial.count = wmaterial.count + mlog.count_ok
|
||||
wmaterial.save()
|
||||
if material_out.is_hidden is False: # 需要入车间库存
|
||||
if material_out.brothers and Mlogb.objects.filter(mlog=mlog).exists():
|
||||
for item in Mlogb.objects.filter(mlog=mlog):
|
||||
wmaterial, _ = WMaterial.objects.get_or_create(batch=mlog.batch, material=item.material_out, belong_dept=belong_dept, defaults={
|
||||
'batch': mlog.batch, 'material': item.material_out, 'belong_dept': belong_dept
|
||||
})
|
||||
wmaterial.count = wmaterial.count + item.count_ok
|
||||
wmaterial.save()
|
||||
else:
|
||||
wmaterial, _ = WMaterial.objects.get_or_create(batch=mlog.batch, material=material_out, belong_dept=belong_dept, defaults={
|
||||
'batch': mlog.batch, 'material': material_out, 'belong_dept': belong_dept
|
||||
})
|
||||
wmaterial.count = wmaterial.count + mlog.count_ok
|
||||
wmaterial.save()
|
||||
|
||||
|
||||
def update_mtask(mtask: Mtask):
|
||||
|
|
Loading…
Reference in New Issue