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