1
0
mirror of https://gitlab.crans.org/bde/nk20 synced 2024-12-23 07:52:23 +00:00

Fix SpecialTransaction proxies

This commit is contained in:
Yohann D'ANELLO 2020-03-23 22:13:16 +01:00
parent cf45b08c5b
commit d6e00f7bba

View File

@ -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)
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)