feat: mgroup增加自产和外协字段及相关逻辑校验
This commit is contained in:
parent
459fc3bbe8
commit
a0084f7825
|
@ -529,7 +529,7 @@ class MlogSerializer(CustomModelSerializer):
|
||||||
def validate(self, attrs):
|
def validate(self, attrs):
|
||||||
attrs['fill_way'] = Mlog.MLOG_2 # 只填第二级
|
attrs['fill_way'] = Mlog.MLOG_2 # 只填第二级
|
||||||
attrs['mtype'] = Mlog.MTYPE_SELF # 默认为自生产
|
attrs['mtype'] = Mlog.MTYPE_SELF # 默认为自生产
|
||||||
fmlog = attrs.get('fmlog', None)
|
fmlog:Fmlog = attrs.get('fmlog', None)
|
||||||
mtaskb = attrs.get('mtaskb', None)
|
mtaskb = attrs.get('mtaskb', None)
|
||||||
if fmlog:
|
if fmlog:
|
||||||
attrs['fill_way'] = Mlog.MLOG_12
|
attrs['fill_way'] = Mlog.MLOG_12
|
||||||
|
@ -540,6 +540,7 @@ class MlogSerializer(CustomModelSerializer):
|
||||||
raise ParseError('未提供消耗的车间物料')
|
raise ParseError('未提供消耗的车间物料')
|
||||||
attrs['mgroup'] = fmlog.mgroup
|
attrs['mgroup'] = fmlog.mgroup
|
||||||
attrs['mtask'] = fmlog.mtask
|
attrs['mtask'] = fmlog.mtask
|
||||||
|
attrs['mtype'] = fmlog.mgroup.mtype
|
||||||
if attrs['mtask'].route:
|
if attrs['mtask'].route:
|
||||||
attrs['route'] = attrs['mtask'].route
|
attrs['route'] = attrs['mtask'].route
|
||||||
# if attrs['mtask'].mtaskb and mtaskb is None:
|
# if attrs['mtask'].mtaskb and mtaskb is None:
|
||||||
|
@ -552,6 +553,10 @@ class MlogSerializer(CustomModelSerializer):
|
||||||
raise ParseError('非合格品不可使用')
|
raise ParseError('非合格品不可使用')
|
||||||
if wm_in.material != attrs['mtask'].material_in:
|
if wm_in.material != attrs['mtask'].material_in:
|
||||||
raise ParseError('消耗物料与任务不一致')
|
raise ParseError('消耗物料与任务不一致')
|
||||||
|
if attrs['mtype'] == Mlog.MTYPE_OUT:
|
||||||
|
supplier = attrs.get('supplier', None)
|
||||||
|
if not supplier:
|
||||||
|
raise ParseError('外协必须选择外协单位')
|
||||||
mtask = attrs.get('mtask', None)
|
mtask = attrs.get('mtask', None)
|
||||||
count_notok = 0
|
count_notok = 0
|
||||||
for i in attrs:
|
for i in attrs:
|
||||||
|
|
Loading…
Reference in New Issue