Fix update_sum left in transaction models
This commit is contained in:
parent
0c5ba6899b
commit
ec5c0e2fef
3 changed files with 2 additions and 13 deletions
|
@ -7,6 +7,5 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% else %}
|
|
||||||
{% include "django/forms/widgets/select.html" %}
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% include "django/forms/widgets/select.html" %}
|
||||||
|
|
|
@ -102,6 +102,7 @@ class TransactionForm(NummiForm):
|
||||||
|
|
||||||
if _disable_statement:
|
if _disable_statement:
|
||||||
self.fields["statement"].disabled = True
|
self.fields["statement"].disabled = True
|
||||||
|
self.fields["statement"].widget.attrs["hidden"] = True
|
||||||
|
|
||||||
|
|
||||||
class InvoiceForm(NummiForm):
|
class InvoiceForm(NummiForm):
|
||||||
|
|
|
@ -44,17 +44,6 @@ class Transaction(UserModel):
|
||||||
verbose_name=_("Statement"),
|
verbose_name=_("Statement"),
|
||||||
)
|
)
|
||||||
|
|
||||||
def save(self, *args, **kwargs):
|
|
||||||
if Transaction.objects.filter(pk=self.pk):
|
|
||||||
prev_self = Transaction.objects.get(pk=self.pk)
|
|
||||||
else:
|
|
||||||
prev_self = None
|
|
||||||
super().save(*args, **kwargs)
|
|
||||||
if prev_self is not None and prev_self.statement:
|
|
||||||
prev_self.statement.update_sum()
|
|
||||||
if self.statement:
|
|
||||||
self.statement.update_sum()
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f"{self.name}"
|
return f"{self.name}"
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue