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 2964dfb..f6db6c0 100644 --- a/apps/product/web/api/v1/serializers/quota_distribution_serializers.py +++ b/apps/product/web/api/v1/serializers/quota_distribution_serializers.py @@ -65,7 +65,10 @@ class QuotaDistributionSerializer(serializers.ModelSerializer): if total + amount > quota.quota_weight: raise QuotaWeightException() else: - if parent_distribution.weight + amount > parent_distribution.weight: + children_total = parent_distribution.children.all().aggregate( + total=models.Sum('weight') + )['total'] or 0 + if children_total + amount > parent_distribution.weight: raise QuotaWeightException() if self.instance: diff --git a/logs/django_requests.log b/logs/django_requests.log index fd9b716..9e221d0 100644 --- a/logs/django_requests.log +++ b/logs/django_requests.log @@ -1262,3 +1262,16 @@ TypeError: 'NoneType' object is not iterable [2025-11-04 13:56:49,907] INFO django.server | IP: - | Path: - | "GET /product/pos/api/v1/distributions/rancher_distributions/?national_code=4050820765 HTTP/1.1" 200 135 [2025-11-04 14:41:31,421] INFO django.utils.autoreload | IP: - | Path: - | D:\Project\Rasaddam_Backend\apps\product\web\api\v1\serializers\quota_distribution_serializers.py changed, reloading. [2025-11-04 14:41:36,126] INFO django.utils.autoreload | IP: - | Path: - | Watching for file changes with StatReloader +[2025-11-04 14:46:07,879] WARNING django.request | IP: 127.0.0.1 | Path: /pos_device/web/v1/pos/holders_share/ | Bad Request: /pos_device/web/v1/pos/holders_share/ +[2025-11-04 14:46:07,879] WARNING django.server | IP: - | Path: - | "POST /pos_device/web/v1/pos/holders_share/ HTTP/1.1" 400 161 +[2025-11-04 14:46:17,410] INFO django.utils.autoreload | IP: - | Path: - | D:\Project\Rasaddam_Backend\apps\product\web\api\v1\serializers\quota_distribution_serializers.py changed, reloading. +[2025-11-04 14:46:22,208] INFO django.utils.autoreload | IP: - | Path: - | Watching for file changes with StatReloader +[2025-11-04 14:46:28,564] WARNING django.request | IP: 127.0.0.1 | Path: /pos_device/web/v1/pos/holders_share/ | Bad Request: /pos_device/web/v1/pos/holders_share/ +[2025-11-04 14:46:28,565] WARNING django.server | IP: - | Path: - | "POST /pos_device/web/v1/pos/holders_share/ HTTP/1.1" 400 161 +[2025-11-04 14:46:38,910] INFO django.utils.autoreload | IP: - | Path: - | D:\Project\Rasaddam_Backend\apps\product\web\api\v1\serializers\quota_distribution_serializers.py changed, reloading. +[2025-11-04 14:46:43,043] INFO django.utils.autoreload | IP: - | Path: - | Watching for file changes with StatReloader +[2025-11-04 14:46:48,181] WARNING django.request | IP: 127.0.0.1 | Path: /pos_device/web/v1/pos/holders_share/ | Bad Request: /pos_device/web/v1/pos/holders_share/ +[2025-11-04 14:46:48,181] WARNING django.server | IP: - | Path: - | "POST /pos_device/web/v1/pos/holders_share/ HTTP/1.1" 400 161 +[2025-11-04 14:48:29,357] INFO django.utils.autoreload | IP: - | Path: - | D:\Project\Rasaddam_Backend\apps\product\web\api\v1\serializers\quota_distribution_serializers.py changed, reloading. +[2025-11-04 14:48:32,974] INFO django.utils.autoreload | IP: - | Path: - | Watching for file changes with StatReloader +[2025-11-04 14:48:39,380] INFO django.server | IP: - | Path: - | "POST /pos_device/web/v1/pos/holders_share/ HTTP/1.1" 201 6444