Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions account_financial_report/wizard/aged_partner_balance_wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,16 @@ def on_change_account_range(self):
):
start_range = int(self.account_code_from.code)
end_range = int(self.account_code_to.code)
self.account_ids = self.env["account.account"].search(
[
("code", ">=", start_range),
("code", "<=", end_range),
("reconcile", "=", True),
]
)
domain = [
("code", ">=", start_range),
("code", "<=", end_range),
("reconcile", "=", True),
]

if self.company_id:
self.account_ids = self.account_ids.filtered(
lambda a: self.company_id in a.company_ids
)
domain.append(("company_ids", "in", [self.company_id.id]))

self.account_ids = self.env["account.account"].search(domain)
return {
"domain": {
"account_code_from": [("reconcile", "=", True)],
Expand Down
17 changes: 7 additions & 10 deletions account_financial_report/wizard/open_items_wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,14 @@ def on_change_account_range(self):
):
start_range = int(self.account_code_from.code)
end_range = int(self.account_code_to.code)
self.account_ids = self.env["account.account"].search(
[
("code", ">=", start_range),
("code", "<=", end_range),
("reconcile", "=", True),
]
)
domain = [
("code", ">=", start_range),
("code", "<=", end_range),
("reconcile", "=", True),
]
if self.company_id:
self.account_ids = self.account_ids.filtered(
lambda a: self.company_id in a.company_ids
)
domain.append(("company_ids", "in", [self.company_id.id]))
self.account_ids = self.env["account.account"].search(domain)
return {
"domain": {
"account_code_from": [("reconcile", "=", True)],
Expand Down
21 changes: 6 additions & 15 deletions account_financial_report/wizard/trial_balance_wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,21 +88,12 @@ def on_change_account_range(self):
):
start_range = self.account_code_from.code
end_range = self.account_code_to.code
self.account_ids = self.env["account.account"].search(
[("code", ">=", start_range), ("code", "<=", end_range)]
)
if isinstance(self.account_ids[0].id, models.NewId):
real_ids = self.account_ids.ids
account_ids = self.env["account.account"].browse(real_ids)
if self.company_id:
self.account_ids = account_ids.filtered(
lambda a: self.company_id in a.company_ids
)
else:
if self.company_id:
self.account_ids = self.account_ids.filtered(
lambda a: self.company_id in a.company_ids
)
domain = [("code", ">=", start_range), ("code", "<=", end_range)]

if self.company_id:
domain.append(("company_ids", "in", [self.company_id.id]))

self.account_ids = self.env["account.account"].search(domain)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is not clear to me why we no longer have to handle the NewId case here. Could you enlighten me?

Copy link
Author

@Ricardoalso Ricardoalso Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because this is an onchange method on an unsaved Transient Model record. Odoo wraps the assigned records with NewId objects. By calling the filtered on those records of NewId type, it fails.

And now we are only calling the search method once with the adapted domain, improving overall performances also.


@api.constrains("show_hierarchy", "show_hierarchy_level")
def _check_show_hierarchy_level(self):
Expand Down