Revised the txn_form view to constructs the new transaction form without having to bother the make_txn_form_from_model() utility, in order not to mess up with the is_bound form property, to replace the need for the should_validate template variable, and removed all the should_validate template variables from the transaction form templates in the accounting application.

This commit is contained in:
依瑪貓
2020-08-12 11:59:50 +08:00
parent 5fc337b39d
commit 05892b9655
7 changed files with 41 additions and 44 deletions

View File

@ -294,7 +294,7 @@ class TransactionForm(forms.Form):
int: The total amount of the credit records.
"""
return sum([int(x.data["amount"]) for x in self.debit_records
if "amount" not in x.errors])
if "amount" in x.data and "amount" not in x.errors])
def credit_total(self):
"""Returns the total amount of the credit records.
@ -303,7 +303,7 @@ class TransactionForm(forms.Form):
int: The total amount of the credit records.
"""
return sum([int(x.data["amount"]) for x in self.credit_records
if "amount" not in x.errors])
if "amount" in x.data and "amount" not in x.errors])
class AccountForm(forms.Form):