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