From efa0ab3950aaea3a416817908563e86367ca10ed Mon Sep 17 00:00:00 2001 From: Mojtaba-z Date: Sat, 9 Aug 2025 16:51:31 +0330 Subject: [PATCH] fix distributoion creation bug --- .../quota_distribution_serializers.py | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/apps/product/web/api/v1/serializers/quota_distribution_serializers.py b/apps/product/web/api/v1/serializers/quota_distribution_serializers.py index 103033f..20d98e2 100644 --- a/apps/product/web/api/v1/serializers/quota_distribution_serializers.py +++ b/apps/product/web/api/v1/serializers/quota_distribution_serializers.py @@ -56,17 +56,17 @@ class QuotaDistributionSerializer(serializers.ModelSerializer): if total + amount > quota.quota_weight: raise QuotaWeightException() - # total warehouse inventory entry - total_entry = self.instance.inventory_entry.aggregate( - total=models.Sum('weight') - )['total'] or 0 - - # if inventory entry weight is bigger than distribute weight in edit distribution - if total_entry > self.instance.weight: - raise APIException("وزن وارد شده کمتر از وزن ورودی به انبار است", code=403) # noqa - - # if weight is more than distribution remaining weight if self.instance: + # total warehouse inventory entry + total_entry = self.instance.inventory_entry.aggregate( + total=models.Sum('weight') + )['total'] or 0 + + # if inventory entry weight is bigger than distribute weight in edit distribution + if total_entry > self.instance.weight: + raise APIException("وزن وارد شده کمتر از وزن ورودی به انبار است", code=403) # noqa + + # if weight is more than distribution remaining weight if self.instance.weight > self.instance.remaining_weight: raise APIException("وزن وارد شده بیشتر از وزن باقیمانده است", code=403) # noqa