From d6e00f7bbaa8b817d293df44a51e5df7fd40c619 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Mon, 23 Mar 2020 22:13:16 +0100 Subject: [PATCH] Fix SpecialTransaction proxies --- apps/treasury/apps.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/apps/treasury/apps.py b/apps/treasury/apps.py index bc492aa7..14ca36e7 100644 --- a/apps/treasury/apps.py +++ b/apps/treasury/apps.py @@ -2,7 +2,7 @@ # SPDX-License-Identifier: GPL-3.0-or-later from django.apps import AppConfig -from django.db.models.signals import post_save +from django.db.models.signals import post_save, post_migrate from django.utils.translation import gettext_lazy as _ @@ -20,6 +20,9 @@ class TreasuryConfig(AppConfig): from treasury.models import SpecialTransactionProxy post_save.connect(signals.save_special_transaction, sender=SpecialTransaction) - # If the treasury app was disabled, we ensure that each special transaction is linked to a proxy - for transaction in SpecialTransaction.objects.filter(specialtransactionproxy=None): - SpecialTransactionProxy.objects.create(transaction=transaction, remittance=None) + def setup_specialtransactions_proxies(**kwargs): + # If the treasury app was disabled, we ensure that each special transaction is linked to a proxy + for transaction in SpecialTransaction.objects.filter(specialtransactionproxy=None): + SpecialTransactionProxy.objects.create(transaction=transaction, remittance=None) + + post_migrate.connect(setup_specialtransactions_proxies, sender=SpecialTransactionProxy)