diff --git a/apps/treasury/apps.py b/apps/treasury/apps.py index e2873ea2..f3fbe092 100644 --- a/apps/treasury/apps.py +++ b/apps/treasury/apps.py @@ -28,6 +28,8 @@ class TreasuryConfig(AppConfig): source__in=NoteSpecial.objects.filter(~Q(remittancetype=None)), specialtransactionproxy=None, ): - SpecialTransactionProxy.objects.create(transaction=transaction, remittance=None) + proxy = SpecialTransactionProxy(transaction=transaction, remittance=None) + proxy._force_save = True + proxy.save() post_migrate.connect(setup_specialtransactions_proxies, sender=SpecialTransactionProxy) diff --git a/apps/treasury/signals.py b/apps/treasury/signals.py index f08540d1..5604b3c1 100644 --- a/apps/treasury/signals.py +++ b/apps/treasury/signals.py @@ -10,9 +10,8 @@ def save_special_transaction(instance, created, **kwargs): """ if not hasattr(instance, "_no_signal"): - if instance.is_credit(): - if created and RemittanceType.objects.filter(note=instance.source).exists(): - SpecialTransactionProxy.objects.create(transaction=instance, remittance=None).save() - else: - if created and RemittanceType.objects.filter(note=instance.destination).exists(): - SpecialTransactionProxy.objects.create(transaction=instance, remittance=None).save() + if created and RemittanceType.objects.filter( + note=instance.source if instance.is_credit() else instance.destination).exists(): + proxy = SpecialTransactionProxy(transaction=instance, remittance=None) + proxy._force_save = True + proxy.save()