From 296f8a3c0ed5b16eb1a7724a540fc4fbdb83c9b8 Mon Sep 17 00:00:00 2001 From: Mojtaba-z Date: Sun, 16 Nov 2025 11:56:31 +0330 Subject: [PATCH] some changes --- apps/product/models.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/apps/product/models.py b/apps/product/models.py index e4b9ecc..aba7434 100644 --- a/apps/product/models.py +++ b/apps/product/models.py @@ -823,9 +823,13 @@ class OrganizationQuotaStats(BaseModel): from apps.warehouse.models import InventoryQuotaSaleItem # calculate total amount of distribution - self.total_distributed = self.distributions.filter().aggregate( - total=Sum('weight') - )['total'] or 0 + # self.total_amount = self.distributions.filter().aggregate( + # total=Sum('weight') + # )['total'] or 0 + + self.total_distributed = self.distributions.filter().exclude( + assigned_organization=self.organization + ).aggregate(total=Sum('weight'))['total'] or 0 self.sold_amount = InventoryQuotaSaleItem.objects.filter( quota_distribution__in=self.distributions.all(), @@ -834,7 +838,7 @@ class OrganizationQuotaStats(BaseModel): total=Sum('weight') )['total'] or 0 - self.remaining_amount = self.total_amount - self.sold_amount + self.remaining_amount = self.total_amount - self.total_distributed self.save()