Replaced querying the accounts later with the "selectinload" query option in the journal and search reports, and restored the lazy setting in the account relationship of the JournalEntry data model.

This commit is contained in:
2023-03-09 07:21:01 +08:00
parent 21b3320e66
commit 13e3ef5875
4 changed files with 48 additions and 47 deletions

View File

@ -22,6 +22,7 @@ from decimal import Decimal
import sqlalchemy as sa
from flask import Response, render_template, request
from sqlalchemy.orm import selectinload
from accounting.locale import gettext
from accounting.models import Currency, CurrencyL10n, Account, AccountL10n, \
@ -67,7 +68,8 @@ class EntryCollector:
except ArithmeticError:
pass
conditions.append(sa.or_(*sub_conditions))
return [ReportEntry(x) for x in JournalEntry.query.filter(*conditions)]
return [ReportEntry(x) for x in JournalEntry.query.filter(*conditions)
.options(selectinload(JournalEntry.account))]
@staticmethod
def __get_account_condition(k: str) -> sa.Select: