fix: mlog update时mlogb不更新
This commit is contained in:
parent
08f9fa106a
commit
d483bb6b61
|
@ -271,20 +271,10 @@ class MlogSerializer(CustomModelSerializer):
|
||||||
with transaction.atomic():
|
with transaction.atomic():
|
||||||
mlogb = validated_data.pop('mlogb', [])
|
mlogb = validated_data.pop('mlogb', [])
|
||||||
instance = super().update(instance, validated_data)
|
instance = super().update(instance, validated_data)
|
||||||
brotherId_should_list = instance.material_out.brothers
|
if mlogb:
|
||||||
if brotherId_should_list:
|
Mlogb.objects.filter(mlog=instance).update(count_ok=0)
|
||||||
if mlogb:
|
for item in mlogb:
|
||||||
for item in mlogb:
|
Mlogb.objects.filter(mlog=instance, material_out=item['material_out']).update(count_ok=item['count_ok'])
|
||||||
id = item.get('id', None)
|
|
||||||
if id:
|
|
||||||
mlogb = Mlogb.objects.get(id=id)
|
|
||||||
mlogb.count_ok = item['count_ok']
|
|
||||||
mlogb.save()
|
|
||||||
# elif item['material_out'].id in brotherId_should_list:
|
|
||||||
# Mlogb.objects.create(
|
|
||||||
# mlog=instance, material_out=item['material_out'], count_ok=item['count_ok'])
|
|
||||||
else:
|
|
||||||
raise ValidationError('缺少产出物信息')
|
|
||||||
return instance
|
return instance
|
||||||
|
|
||||||
def validate(self, attrs):
|
def validate(self, attrs):
|
||||||
|
|
Loading…
Reference in New Issue