fix: mlogbinserializer
This commit is contained in:
parent
419b52f9be
commit
f9c9a592e3
|
@ -726,7 +726,7 @@ class MlogbInSerializer(CustomModelSerializer):
|
|||
class Meta:
|
||||
model = Mlogb
|
||||
fields = ['id', 'mlog', 'mtask', 'route', 'wm_in', 'count_use', 'count_pn_jgqbl',
|
||||
'count_break', 'note', "parent", "mlogbdefect", "count_json_from"]
|
||||
'count_break', 'note', "parent", "mlogbdefect", "count_json_from", "wprs_in"]
|
||||
extra_kwargs = {'count_use': {'required': True}, 'mtask': {'required': False},
|
||||
'wm_in': {'required': True, "allow_empty": False}}
|
||||
|
||||
|
@ -778,12 +778,14 @@ class MlogbInSerializer(CustomModelSerializer):
|
|||
mlog: Mlog = validated_data['mlog']
|
||||
mtask: Mtask = validated_data.get("mtask", None)
|
||||
mlogbdefect = validated_data.pop("mlogbdefect", None)
|
||||
wprs_in = validated_data.pop("wprs_in", [])
|
||||
if Mlogb.objects.filter(mlog=mlog, mtask=mtask, wm_in=validated_data['wm_in'], parent=None).exists():
|
||||
raise ParseError('该记录已存在')
|
||||
if mlog.submit_time is not None:
|
||||
raise ParseError('生产日志已提交不可编辑')
|
||||
|
||||
ins:Mlogb = super().create(validated_data)
|
||||
validated_data["wprs_in"] = wprs_in
|
||||
if mlogbdefect is not None and ins.material_in.tracking == Material.MA_TRACKING_BATCH:
|
||||
mlogb_defect_objects = [
|
||||
MlogbDefect(**{**item, "mlogb": ins, "id": idWorker.get_id()})
|
||||
|
|
Loading…
Reference in New Issue