Revised the way to query accounts with Flask-SQLAlchemy style queries in the accounts method of the CurrentAccount data model.

This commit is contained in:
依瑪貓 2023-05-04 09:35:14 +08:00
parent 0b1dd4f4fc
commit 433110f486

View File

@ -21,7 +21,6 @@ from typing import Self
import sqlalchemy as sa import sqlalchemy as sa
from accounting import db
from accounting.locale import gettext from accounting.locale import gettext
from accounting.models import Account from accounting.models import Account
@ -75,7 +74,7 @@ class CurrentAccount:
""" """
accounts: list[cls] = [cls.current_assets_and_liabilities()] accounts: list[cls] = [cls.current_assets_and_liabilities()]
accounts.extend([CurrentAccount(x) accounts.extend([CurrentAccount(x)
for x in db.session.query(Account) for x in Account.query
.filter(cls.sql_condition()) .filter(cls.sql_condition())
.order_by(Account.base_code, Account.no)]) .order_by(Account.base_code, Account.no)])
return accounts return accounts