transaction system deploying
This commit is contained in:
@@ -3,6 +3,7 @@ from apps.product.models import QuotaDistribution
|
||||
from apps.warehouse.models import InventoryQuotaSaleTransaction
|
||||
from apps.authentication.models import Organization, OrganizationStats
|
||||
from django.db.models.signals import post_save, post_delete
|
||||
from rest_framework.exceptions import APIException
|
||||
from django.dispatch import receiver
|
||||
|
||||
|
||||
@@ -38,6 +39,12 @@ def update_organization_stats(instance: Organization):
|
||||
@receiver([post_save, post_delete], sender=InventoryQuotaSaleTransaction)
|
||||
def organization_stats(sender, instance, **kwargs):
|
||||
if sender == QuotaDistribution:
|
||||
update_organization_stats(instance.assigned_organization)
|
||||
if instance.assigned_organization:
|
||||
update_organization_stats(instance.assigned_organization)
|
||||
else:
|
||||
print("assigned_organization is null")
|
||||
elif sender == InventoryQuotaSaleTransaction:
|
||||
update_organization_stats(instance.inventory_entry.organization)
|
||||
if instance.inventory_entry:
|
||||
update_organization_stats(instance.inventory_entry.organization)
|
||||
else:
|
||||
print("inventory_entry is null - authentication app signals")
|
||||
|
||||
Reference in New Issue
Block a user