Replaced the get_absolute_url() method in the account data model with the get_success_url() method in the account form model, and added the current application to the arguments to enable multiple instances of the application in the accounting application.
This commit is contained in:
parent
64769440a7
commit
b3e18d547d
@ -18,14 +18,12 @@
|
|||||||
"""The data models of the accounting application.
|
"""The data models of the accounting application.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
import datetime
|
|
||||||
from typing import Dict, List, Optional
|
from typing import Dict, List, Optional
|
||||||
|
|
||||||
from dirtyfields import DirtyFieldsMixin
|
from dirtyfields import DirtyFieldsMixin
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.db import models, transaction
|
from django.db import models, transaction
|
||||||
from django.db.models import Q, Max
|
from django.db.models import Q, Max
|
||||||
from django.urls import reverse
|
|
||||||
|
|
||||||
from mia_core.utils import get_multi_lingual_attr, set_multi_lingual_attr, \
|
from mia_core.utils import get_multi_lingual_attr, set_multi_lingual_attr, \
|
||||||
new_pk
|
new_pk
|
||||||
@ -83,10 +81,6 @@ class Account(DirtyFieldsMixin, models.Model):
|
|||||||
super().save(force_insert=force_insert, force_update=force_update,
|
super().save(force_insert=force_insert, force_update=force_update,
|
||||||
using=using, update_fields=update_fields)
|
using=using, update_fields=update_fields)
|
||||||
|
|
||||||
def get_absolute_url(self):
|
|
||||||
"""REturns the """
|
|
||||||
return reverse("accounting:accounts.detail", args=(self,))
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
db_table = "accounting_accounts"
|
db_table = "accounting_accounts"
|
||||||
|
|
||||||
|
@ -979,6 +979,11 @@ class AccountFormView(FormView):
|
|||||||
"""Returns the current object, or None on a create form."""
|
"""Returns the current object, or None on a create form."""
|
||||||
return self.kwargs.get("account")
|
return self.kwargs.get("account")
|
||||||
|
|
||||||
|
def get_success_url(self) -> str:
|
||||||
|
"""Returns the URL on success."""
|
||||||
|
return reverse("accounting:accounts.detail", args=(self.get_object(),),
|
||||||
|
current_app=self.request.resolver_match.namespace)
|
||||||
|
|
||||||
|
|
||||||
@require_POST
|
@require_POST
|
||||||
@login_required
|
@login_required
|
||||||
|
Loading…
Reference in New Issue
Block a user