Skip to content

[19.0][FIX] server_environment: add search support for env-computed fields - #278

Open
AungKoKoLin1997 wants to merge 1 commit into
OCA:19.0from
qrtl:19.0-fix-server-env-search
Open

[19.0][FIX] server_environment: add search support for env-computed fields#278
AungKoKoLin1997 wants to merge 1 commit into
OCA:19.0from
qrtl:19.0-fix-server-env-search

Conversation

@AungKoKoLin1997

@AungKoKoLin1997 AungKoKoLin1997 commented Jul 22, 2026

Copy link
Copy Markdown

Summary

When server_environment transforms a field to an env-computed field, it sets store=False but does not provide a search method. This makes the field unusable in domain filters, e.g.:

storage_id = fields.Many2one(
    comodel_name="storage.backend",
    domain=[("backend_type", "=", "sftp")],
)

raises:

ValueError: Cannot convert storage.backend.backend_type to SQL because it is not stored

This was not an issue before Odoo 19 because the old domain processing (osv.expression) handled non-stored fields more leniently. Odoo 19's rewritten domain engine (odoo.orm.domains) strictly requires either store=True or an explicit search method.

Fix

Add a search method for env-computed fields following the same _partialmethod pattern already used for the inverse method.

@qrtl QT7028

@OCA-git-bot OCA-git-bot added mod:server_environment Module server_environment series:19.0 labels Jul 22, 2026
@AungKoKoLin1997
AungKoKoLin1997 force-pushed the 19.0-fix-server-env-search branch from 6cf2396 to 7ea5b66 Compare July 22, 2026 08:55
@AungKoKoLin1997 AungKoKoLin1997 changed the title [FIX] server_environment: add search support for env-computed fields [19.0][FIX] server_environment: add search support for env-computed fields Jul 22, 2026
When server_environment transforms a field to an env-computed field,
it sets store=False but does not provide a search method. This makes
the field unusable in domain filters, raising:

  ValueError: Cannot convert <field> to SQL because it is not stored

This was not an issue before Odoo 19 because the old domain processing
(osv.expression) handled non-stored fields more leniently. Odoo 19's
rewritten domain engine (odoo.orm.domains) strictly requires either
store=True or an explicit search method.

Add a search method for env-computed fields following the same
_partialmethod pattern already used for the inverse method.
@AungKoKoLin1997
AungKoKoLin1997 force-pushed the 19.0-fix-server-env-search branch from 7ea5b66 to 8f9c9aa Compare July 24, 2026 03:07
@AungKoKoLin1997
AungKoKoLin1997 marked this pull request as ready for review July 24, 2026 03:07
# env-computed fields are not stored, so we can't search them in SQL.
# Load all records and filter them in memory instead. These config
# models hold very few records, so the full scan is acceptable.
all_records = self.search([]) # pylint: disable=no-search-all

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
all_records = self.search([]) # pylint: disable=no-search-all
all_records = self.with_context(active_test=False).search([]) # pylint: disable=no-search-all

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I don't think we need to search archived records as well. Do you have any reason?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I think it would be better to include active=False support, since this is intended to be a generic search method.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Odoo standard generic search only find the active records, no?

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

Labels

mod:server_environment Module server_environment series:19.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants