[FIX] Account filter on general ledger wizard

This commit both improves perfs by doing a single search() instead of
search() + filtered and also make account selection by interval really
work.
This commit is contained in:
Alexis de Lattre
2025-07-04 18:26:05 +02:00
parent 1731863f59
commit 138b1bff7f

View File

@@ -103,13 +103,10 @@ class GeneralLedgerReportWizard(models.TransientModel):
): ):
start_range = int(self.account_code_from.code) start_range = int(self.account_code_from.code)
end_range = int(self.account_code_to.code) end_range = int(self.account_code_to.code)
self.account_ids = self.env["account.account"].search( domain = [("code", ">=", start_range), ("code", "<=", end_range)]
[("code", ">=", start_range), ("code", "<=", end_range)]
)
if self.company_id: if self.company_id:
self.account_ids = self.account_ids.filtered( domain.append(("company_ids", "in", self.company_id.ids))
lambda a: self.company_id in a.company_ids self.account_ids = self.env["account.account"].search(domain)
)
def _init_date_from(self): def _init_date_from(self):
"""set start date to begin of current year if fiscal year running""" """set start date to begin of current year if fiscal year running"""