[FIX] orm: avoid groupby on models with custom _select#246333
Closed
kmagusiak wants to merge 1 commit intoodoo:saas-19.1from
Closed
[FIX] orm: avoid groupby on models with custom _select#246333kmagusiak wants to merge 1 commit intoodoo:saas-19.1from
_select#246333kmagusiak wants to merge 1 commit intoodoo:saas-19.1from
Conversation
Contributor
rco-odoo
reviewed
Jan 29, 2026
ffc2717 to
455283c
Compare
Comment on lines
+616
to
+617
| if self.env.context.get('_read_groupby'): | ||
| raise ValueError("Cannot group by ir.attachment") |
Contributor
There was a problem hiding this comment.
Is it not only the search_fetch combined with _as_query that causes an issue?
Can't we just move this condition later, if limit is None?
Contributor
Author
There was a problem hiding this comment.
No, this function is also called in read group and in other places of the orm. Technically, the condition can be moved, but it results in some domains working and other not depending on the optimization (quick could change between versions). It's easier to say don't group on all attachments (what would be the use case?)
(still a draft)
Contributor
Author
There was a problem hiding this comment.
I won't move the condition later to keep things consistent.
be8f461 to
6bc9e04
Compare
Add a context to know if we are grouppnig. This allows us to stop `_search` methods which need to search and filter manually all records. For example, when asking if a field is groupable, `_description_groupable` will run a dummy search for many2many fields, for a normal user searching on ir.attachment, it would search for all attachments and try to filter them in memory leading to OOM error.
6bc9e04 to
0fc4843
Compare
Member
|
@robodoo delegate+ |
Contributor
Author
|
@robodoo r+ |
robodoo
pushed a commit
that referenced
this pull request
Feb 5, 2026
Add a context to know if we are grouppnig. This allows us to stop `_search` methods which need to search and filter manually all records. For example, when asking if a field is groupable, `_description_groupable` will run a dummy search for many2many fields, for a normal user searching on ir.attachment, it would search for all attachments and try to filter them in memory leading to OOM error. closes #246333 Signed-off-by: Krzysztof Magusiak (krma) <krma@odoo.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Add a context to know if we are grouppnig. This allows us to stop
_searchmethods which need to search and filter manually all records.For example, when asking if a field is groupable,
_description_groupablewill run a dummy search for many2many fields, for a normal user searching on ir.attachment, it would search for all attachments and try to filter them in memory leading to OOM error.I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr