Skip to content

Conversation

@Ricardoalso
Copy link

@Ricardoalso Ricardoalso commented Jan 15, 2026

Fixing some unfixed on_change_account_range methods following the same approach as the ones done in #1416 and #1293

Useful explanation from the comments

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

A: 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.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants