fix inventory edit weight bug - fix inventory document - set new validations for distribution

This commit is contained in:
2025-08-07 16:59:17 +03:30
parent 82b1dc3637
commit 8e143a0033
4 changed files with 21 additions and 4 deletions

View File

@@ -42,8 +42,12 @@ class InventoryEntrySerializer(serializers.ModelSerializer):
total=models.Sum('weight')
)['total'] or 0
if total_entered + attrs['weight'] > distribution.weight:
raise InventoryEntryWeightException()
if self.instance.weight is 0:
if total_entered + attrs['weight'] > distribution.weight:
raise InventoryEntryWeightException()
elif self.instance.weight is not 0:
if total_entered - self.instance.weight + attrs['weight'] > distribution.weight:
raise InventoryEntryWeightException()
return attrs