A transaction can only be created between active notes
This commit is contained in:
parent
ac5041f3ec
commit
2c7995a79e
2 changed files with 8 additions and 2 deletions
|
|
@ -163,6 +163,12 @@ class Transaction(PolymorphicModel):
|
|||
When saving, also transfer money between two notes
|
||||
"""
|
||||
|
||||
if not self.source.is_active or not self.destination.is_active:
|
||||
if 'force_insert' not in kwargs or not kwargs['force_insert']:
|
||||
if 'force_update' not in kwargs or not kwargs['force_update']:
|
||||
raise ValidationError(_("The transaction can't be saved since the source note "
|
||||
"or the destination note is not active."))
|
||||
|
||||
# If the aliases are not entered, we assume that the used alias is the name of the note
|
||||
if not self.source_alias:
|
||||
self.source_alias = str(self.source)
|
||||
|
|
@ -171,7 +177,7 @@ class Transaction(PolymorphicModel):
|
|||
self.destination_alias = str(self.destination)
|
||||
|
||||
if self.source.pk == self.destination.pk:
|
||||
# When source == destination, no money is transfered
|
||||
# When source == destination, no money is transferred
|
||||
super().save(*args, **kwargs)
|
||||
return
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue