fix - update registerer quota stat in wqrehous allocation service
This commit is contained in:
@@ -55,13 +55,25 @@ class WarehouseAllocationService:
|
||||
)
|
||||
|
||||
org = entry.organization.parent_organization
|
||||
parent_orgs = []
|
||||
while org:
|
||||
stat = OrganizationQuotaStats.objects.filter(
|
||||
quota=entry.quota,
|
||||
organization=org
|
||||
)
|
||||
if stat.exists():
|
||||
stat = stat.first()
|
||||
stat.inventory_received += entry.weight
|
||||
stat.save()
|
||||
# import parent org to list
|
||||
parent_orgs.append(org)
|
||||
org = org.parent_organization
|
||||
|
||||
parent_org_ids = [org.id for org in parent_orgs]
|
||||
|
||||
target_org_ids = set(parent_org_ids)
|
||||
|
||||
if entry.quota.registerer_organization.id not in target_org_ids:
|
||||
target_org_ids.add(entry.quota.registerer_organization.id)
|
||||
|
||||
stats = (OrganizationQuotaStats.objects.filter(
|
||||
quota=entry.quota,
|
||||
organization__in=target_org_ids
|
||||
))
|
||||
|
||||
for stat in stats:
|
||||
stat.inventory_received += entry.weight
|
||||
|
||||
OrganizationQuotaStats.objects.bulk_update(stats, ["inventory_received"])
|
||||
|
||||
Reference in New Issue
Block a user