feat: mlogbin 校验记录已存在
This commit is contained in:
parent
cbedb81b0e
commit
071558af8d
|
|
@ -394,12 +394,16 @@ class MlogbInSerializer(CustomModelSerializer):
|
||||||
|
|
||||||
def create(self, validated_data):
|
def create(self, validated_data):
|
||||||
mlog: Mlog = validated_data['mlog']
|
mlog: Mlog = validated_data['mlog']
|
||||||
|
if Mlogb.objects.filter(mlog=mlog, mtask=validated_data['mtask'], wm_in=validated_data['wm_in']).exists():
|
||||||
|
raise ValidationError('该记录已存在')
|
||||||
if mlog.submit_time is not None:
|
if mlog.submit_time is not None:
|
||||||
raise ParseError('生产日志已提交不可编辑')
|
raise ParseError('生产日志已提交不可编辑')
|
||||||
return super().create(validated_data)
|
return super().create(validated_data)
|
||||||
|
|
||||||
def update(self, instance, validated_data):
|
def update(self, instance, validated_data):
|
||||||
mlog: Mlog = instance.mlog
|
mlog: Mlog = instance.mlog
|
||||||
|
if Mlogb.objects.filter(mlog=mlog, mtask=validated_data['mtask'], wm_in=validated_data['wm_in']).exclude(id=instance.id).exists():
|
||||||
|
raise ValidationError('该记录已存在')
|
||||||
if mlog.submit_time is not None:
|
if mlog.submit_time is not None:
|
||||||
raise ParseError('生产日志已提交不可编辑')
|
raise ParseError('生产日志已提交不可编辑')
|
||||||
return super().update(instance, validated_data)
|
return super().update(instance, validated_data)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue