feat: mlog的need_inout逻辑
This commit is contained in:
parent
6e12ca3137
commit
3811c055f9
|
@ -748,7 +748,7 @@ class MlogbInUpdateSerializer(CustomModelSerializer):
|
|||
mlogbdefect = MlogbDefectSerializer(many=True, required=False)
|
||||
class Meta:
|
||||
model = Mlogb
|
||||
fields = ['id', 'count_use', 'count_pn_jgqbl', 'note', 'mlogbdefect']
|
||||
fields = ['id', 'count_use', 'count_pn_jgqbl', 'note', 'mlogbdefect', "need_inout"]
|
||||
|
||||
def validate(self, attrs):
|
||||
if attrs["count_use"] < 0 or attrs["count_pn_jgqbl"] < 0:
|
||||
|
@ -858,6 +858,16 @@ class MlogbOutUpdateSerializer(CustomModelSerializer):
|
|||
mlogbdefect = validated_data.pop("mlogbdefect", None)
|
||||
with transaction.atomic():
|
||||
ins:Mlogb = super().update(instance, validated_data)
|
||||
if ins.need_inout is False:
|
||||
if ins.mlogb_from:
|
||||
if Mlogb.objects.filter(mlog=ins.mlog, material_out__isnull=False, mlogb_from=ins.mlogb_from).count() == 1:
|
||||
ins_from =Mlogb.objects.filter(mlog=ins.mlog, material_out__isnull=False, mlogb_from=ins.mlogb_from).first()
|
||||
ins_from.need_inout = False
|
||||
ins_from.save(update_fields=["need_inout"])
|
||||
else:
|
||||
raise ParseError("对应消耗的产出有多个, 需手动指定消耗是否出库")
|
||||
else:
|
||||
raise ParseError("该产出需入库!")
|
||||
if mlogbdefect is not None and ins.material_out.tracking == Material.MA_TRACKING_BATCH:
|
||||
MlogbDefect.objects.filter(mlogb=ins).delete()
|
||||
mlogb_defect_objects = [
|
||||
|
|
|
@ -188,7 +188,7 @@ def mlog_submit(mlog: Mlog, user: User, now: Union[datetime.datetime, None]):
|
|||
|
||||
if material_in or is_fix: # 需要进行车间库存管理
|
||||
m_ins_list = []
|
||||
m_ins = Mlogb.objects.filter(mlog=mlog, material_in__isnull=False)
|
||||
m_ins = Mlogb.objects.filter(mlog=mlog, material_in__isnull=False, need_inout=True)
|
||||
if m_ins.exists():
|
||||
m_ins_list = [(mi.material_in, mi.batch if mi.batch else mi.batch, mi.count_use, None, mi) for mi in m_ins.all()]
|
||||
for item in m_ins:
|
||||
|
@ -257,7 +257,7 @@ def mlog_submit(mlog: Mlog, user: User, now: Union[datetime.datetime, None]):
|
|||
|
||||
|
||||
if material_out or is_fix: # 需要入车间库存
|
||||
mlogb_out_qs = Mlogb.objects.filter(mlog=mlog, material_out__isnull=False)
|
||||
mlogb_out_qs = Mlogb.objects.filter(mlog=mlog, material_out__isnull=False, need_inout=True)
|
||||
stored_notok = need_store_notok
|
||||
stored_mgroup = need_store_notok
|
||||
if mlogb_out_qs.exists():
|
||||
|
@ -400,7 +400,7 @@ def mlog_revert(mlog: Mlog, user: User, now: Union[datetime.datetime, None]):
|
|||
if material_out or is_fix: # 产物退回
|
||||
# 有多个产物的情况
|
||||
# 需要考虑不合格品退回的情况
|
||||
mlogb_out_qs = Mlogb.objects.filter(mlog=mlog, material_out__isnull=False)
|
||||
mlogb_out_qs = Mlogb.objects.filter(mlog=mlog, material_out__isnull=False, need_inout=True)
|
||||
if mlogb_out_qs.exists():
|
||||
m_outs_list = [
|
||||
(mo.material_out, mo.batch if mo.batch else mlog.batch, mo.count_ok_full if mo.count_ok_full is not None else mo.count_ok, mlog.count_real_eweight, None, mo)
|
||||
|
@ -495,7 +495,7 @@ def mlog_revert(mlog: Mlog, user: User, now: Union[datetime.datetime, None]):
|
|||
m_ins_list = []
|
||||
m_ins_bl_list = []
|
||||
into_wm_mgroup = process.into_wm_mgroup
|
||||
m_ins = Mlogb.objects.filter(mlog=mlog, material_in__isnull=False)
|
||||
m_ins = Mlogb.objects.filter(mlog=mlog, material_in__isnull=False, need_inout=True)
|
||||
if m_ins.exists():
|
||||
for mi in m_ins.all():
|
||||
m_ins_list.append((mi.material_in, mi.batch, mi.count_use, None, mi))
|
||||
|
|
Loading…
Reference in New Issue