feat: mlogbin支持mtask非必填
This commit is contained in:
parent
5f0d34f9c3
commit
c585f2fc11
|
|
@ -530,20 +530,20 @@ class MlogbInSerializer(CustomModelSerializer):
|
||||||
model = Mlogb
|
model = Mlogb
|
||||||
fields = ['id', 'mlog', 'mtask', 'wm_in', 'count_use', 'count_pn_jgqbl',
|
fields = ['id', 'mlog', 'mtask', 'wm_in', 'count_use', 'count_pn_jgqbl',
|
||||||
'count_break', 'note', "parent"]
|
'count_break', 'note', "parent"]
|
||||||
extra_kwargs = {'count_use': {'required': True}, 'mtask': {'required': True},
|
extra_kwargs = {'count_use': {'required': True}, 'mtask': {'required': False},
|
||||||
'wm_in': {'required': True, "allow_empty": False}}
|
'wm_in': {'required': True, "allow_empty": False}}
|
||||||
|
|
||||||
def validate(self, attrs):
|
def validate(self, attrs):
|
||||||
mlog: Mlog = attrs['mlog']
|
mlog: Mlog = attrs['mlog']
|
||||||
mtask: Mtask = attrs['mtask']
|
mtask: Mtask = attrs.get("mtask", None)
|
||||||
if mtask.state != Mtask.MTASK_ASSGINED:
|
if mtask and mtask.state != Mtask.MTASK_ASSGINED:
|
||||||
raise ValidationError('该任务非下达中不可选择')
|
raise ValidationError('该任务非下达中不可选择')
|
||||||
wm_in: WMaterial = attrs['wm_in']
|
wm_in: WMaterial = attrs['wm_in']
|
||||||
if wm_in.state in [WMaterial.WM_OK, WMaterial.WM_REPAIR]:
|
if wm_in.state in [WMaterial.WM_OK, WMaterial.WM_REPAIR]:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
raise ValidationError('非合格/返修品不可使用')
|
raise ValidationError('非合格/返修品不可使用')
|
||||||
if mlog.route != mtask.route:
|
if mtask and mlog.route != mtask.route:
|
||||||
raise ValidationError('工序不匹配')
|
raise ValidationError('工序不匹配')
|
||||||
route = mlog.route
|
route = mlog.route
|
||||||
attrs['material_in'] = wm_in.material
|
attrs['material_in'] = wm_in.material
|
||||||
|
|
|
||||||
|
|
@ -542,7 +542,7 @@ class MlogbInViewSet(CreateModelMixin, UpdateModelMixin, DestroyModelMixin, Cust
|
||||||
mlog:Mlog = mlogbin.mlog
|
mlog:Mlog = mlogbin.mlog
|
||||||
route:Route = mlog.route
|
route:Route = mlog.route
|
||||||
# 以及mlogbw
|
# 以及mlogbw
|
||||||
if mlogbin.mtask and mlogbin.material_in:
|
if mlogbin.material_in:
|
||||||
material_in:Material = mlogbin.material_in
|
material_in:Material = mlogbin.material_in
|
||||||
material_out:Material = mlog.material_out
|
material_out:Material = mlog.material_out
|
||||||
if material_out is None:
|
if material_out is None:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue