diff --git a/accounting/models.py b/accounting/models.py index 6b08eeb..0086f9a 100644 --- a/accounting/models.py +++ b/accounting/models.py @@ -160,18 +160,6 @@ class Transaction(DirtyFieldsMixin, models.Model): transaction.""" return self.date.__str__() + " #" + self.ord.__str__() - def get_absolute_url(self) -> str: - """Returns the URL to view this transaction.""" - if self.is_cash_expense: - return reverse( - "accounting:transactions.detail", args=("expense", self)) - elif self.is_cash_income: - return reverse( - "accounting:transactions.detail", args=("income", self)) - else: - return reverse( - "accounting:transactions.detail", args=("transfer", self)) - def is_dirty(self, check_relationship=False, check_m2m=None) -> bool: """Returns whether the data of this transaction is changed and need to be saved into the database. diff --git a/accounting/views.py b/accounting/views.py index be9cc23..99639b5 100644 --- a/accounting/views.py +++ b/accounting/views.py @@ -860,6 +860,12 @@ class TransactionFormView(FormView): """Returns the current object, or None on a create form.""" return self.kwargs.get("txn") + def get_success_url(self) -> str: + """Returns the URL on success.""" + return reverse("accounting:transactions.detail", + args=(self.txn_type, self.get_object()), + current_app=self.request.resolver_match.namespace) + @property def txn_type(self) -> str: """Returns the transaction type of this form."""