1
0
mirror of https://gitlab.crans.org/bde/nk20 synced 2025-06-21 09:58:23 +02:00

Remove useless category field in RecurrentTransaction (that is the category of the template)

This commit is contained in:
Yohann D'ANELLO
2020-09-01 15:51:47 +02:00
parent be08c12dca
commit 2b70a05a9e
3 changed files with 24 additions and 21 deletions

View File

@ -273,10 +273,15 @@ class RecurrentTransaction(Transaction):
on_delete=models.PROTECT,
)
category = models.ForeignKey(
TemplateCategory,
on_delete=models.PROTECT,
)
def clean(self):
if self.template.destination != self.destination:
raise ValidationError(
_("The destination of this transaction must equal to the destination of the template."))
return super().clean()
def save(self, *args, **kwargs):
self.clean()
return super().save(*args, **kwargs)
@property
def type(self):
@ -324,6 +329,10 @@ class SpecialTransaction(Transaction):
raise(ValidationError(_("A special transaction is only possible between a"
" Note associated to a payment method and a User or a Club")))
def save(self, *args, **kwargs):
self.clean()
super().save(*args, **kwargs)
class Meta:
verbose_name = _("Special transaction")
verbose_name_plural = _("Special transactions")