feat(currencies): allow archiving

This commit is contained in:
Herculino Trotta
2025-08-29 22:47:00 -03:00
parent 4565dc770b
commit 1abe9e9f62
7 changed files with 50 additions and 0 deletions

View File

@@ -3,6 +3,7 @@ from crispy_forms.bootstrap import FormActions
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Layout, Field, Column, Row
from django import forms
from django.db.models import Q
from django.utils.translation import gettext_lazy as _
from apps.accounts.models import Account
@@ -15,6 +16,7 @@ from apps.common.widgets.crispy.submit import NoClassSubmit
from apps.common.widgets.tom_select import TomSelect
from apps.transactions.models import TransactionCategory, TransactionTag
from apps.common.widgets.decimal import ArbitraryDecimalDisplayNumberInput
from apps.currencies.models import Currency
class AccountGroupForm(forms.ModelForm):
@@ -79,6 +81,24 @@ class AccountForm(forms.ModelForm):
self.fields["group"].queryset = AccountGroup.objects.all()
if self.instance.id:
self.fields["currency"].queryset = Currency.objects.filter(
Q(is_archived=False) | Q(accounts=self.instance.id),
)
self.fields["exchange_currency"].queryset = Currency.objects.filter(
Q(is_archived=False) | Q(accounts=self.instance.id)
)
else:
self.fields["currency"].queryset = Currency.objects.filter(
Q(is_archived=False),
)
self.fields["exchange_currency"].queryset = Currency.objects.filter(
Q(is_archived=False)
)
self.helper = FormHelper()
self.helper.form_tag = False
self.helper.form_method = "post"