Skip to content

[19.0][MIG] base_search_fuzzy: Migration to 19.0#3620

Open
dnplkndll wants to merge 49 commits into
OCA:19.0from
ledoent:19.0-mig-base_search_fuzzy
Open

[19.0][MIG] base_search_fuzzy: Migration to 19.0#3620
dnplkndll wants to merge 49 commits into
OCA:19.0from
ledoent:19.0-mig-base_search_fuzzy

Conversation

@dnplkndll
Copy link
Copy Markdown
Contributor

@dnplkndll dnplkndll commented May 20, 2026

Port of base_search_fuzzy from 18.0 to 19.0.
Migration guide: https://github.com/OCA/maintainer-tools/wiki/Migration-to-version-19.0

Non-mechanical adaptations worth flagging

The 18.0 post_load hook mutated odoo.osv.expression.TERM_OPERATORS / SQL_OPERATORS to register the trigram % operator. That path is gone in 19.0 (SQL_OPERATORS moved to odoo.orm.utils; the Domain validator keys off odoo.orm.domains.CONDITION_OPERATORS; Field._condition_to_sql raises NotImplementedError for unknown operators). Re-implemented by registering at import time via @operator_optimization(['%']) and emitting the predicate through Domain.custom(to_sql=...). post_load + hooks.py removed.

19.0 relevance

Odoo 19 core added trigram support, but only for like/ilike/= acceleration via a declarative index='trigram' field attribute (fields_textual.py condition_to_sql prefilter, incl. translatable jsonb fields). Core does not expose a fuzzy % similarity domain operator (% is absent from CONDITION_OPERATORS; no word_similarity/set_limit in core ORM), nor dynamic UI-driven index management. Those remain this module's purpose, so it stays distinct on 19.0. The one thing core caught up on — trigram on translatable fields — is exactly the scope trimmed below.

Scope

Per @carlos-lopez-tecnativa's review: dropped the out-of-scope jsonb/translatable-field guard — core already handles trigram on translatable fields for its like/ilike path (functional index over jsonb_path_query_array(col,'$.*')::text in odoo/tools/sql.py), so the module needs no special handling. The round-trip index test uses res.partner.ref (plain text); the translatable-field test asserts WHERE-clause generation only.

Christoph Giesel and others added 30 commits May 20, 2026 19:02
…s, added translations, added access permissions, moved the monkey patching to method _register_hook of ir.model and fixed _auto_init, added README, cleaned up some aprts
…references to odoo * Bump version * Upgrade api usages
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: server-tools-12.0/server-tools-12.0-base_search_fuzzy
Translate-URL: https://translation.odoo-community.org/projects/server-tools-12-0/server-tools-12-0-base_search_fuzzy/
Currently translated at 94.7% (18 of 19 strings)

Translation: server-tools-12.0/server-tools-12.0-base_search_fuzzy
Translate-URL: https://translation.odoo-community.org/projects/server-tools-12-0/server-tools-12-0-base_search_fuzzy/pt/
Currently translated at 100.0% (19 of 19 strings)

Translation: server-tools-12.0/server-tools-12.0-base_search_fuzzy
Translate-URL: https://translation.odoo-community.org/projects/server-tools-12-0/server-tools-12-0-base_search_fuzzy/pt_BR/
Currently translated at 100.0% (19 of 19 strings)

Translation: server-tools-12.0/server-tools-12.0-base_search_fuzzy
Translate-URL: https://translation.odoo-community.org/projects/server-tools-12-0/server-tools-12-0-base_search_fuzzy/zh_CN/
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: server-tools-13.0/server-tools-13.0-base_search_fuzzy
Translate-URL: https://translation.odoo-community.org/projects/server-tools-13-0/server-tools-13-0-base_search_fuzzy/
- [Server-wide patching should be done in `post_load` hook][1], and there's where it's done now.
- Remove similarity order, as it had no use in the wild and was buggy.
- Refactor monkey patch to remove some nonsense.
- Move tests to at_install mode, now that the patch is installed correctly.

@Tecnativa TT31444
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: server-tools-14.0/server-tools-14.0-base_search_fuzzy
Translate-URL: https://translation.odoo-community.org/projects/server-tools-14-0/server-tools-14-0-base_search_fuzzy/
Currently translated at 100.0% (18 of 18 strings)

Translation: server-tools-14.0/server-tools-14.0-base_search_fuzzy
Translate-URL: https://translation.odoo-community.org/projects/server-tools-14-0/server-tools-14-0-base_search_fuzzy/pt_BR/
[ADD] Roadmap: Module no longer needed from v16
Currently translated at 100.0% (18 of 18 strings)

Translation: server-tools-15.0/server-tools-15.0-base_search_fuzzy
Translate-URL: https://translation.odoo-community.org/projects/server-tools-15-0/server-tools-15-0-base_search_fuzzy/es_AR/
oca-ci and others added 13 commits May 20, 2026 19:02
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: server-tools-16.0/server-tools-16.0-base_search_fuzzy
Translate-URL: https://translation.odoo-community.org/projects/server-tools-16-0/server-tools-16-0-base_search_fuzzy/
Currently translated at 100.0% (18 of 18 strings)

Translation: server-tools-16.0/server-tools-16.0-base_search_fuzzy
Translate-URL: https://translation.odoo-community.org/projects/server-tools-16-0/server-tools-16-0-base_search_fuzzy/es/
Currently translated at 100.0% (18 of 18 strings)

Translation: server-tools-16.0/server-tools-16.0-base_search_fuzzy
Translate-URL: https://translation.odoo-community.org/projects/server-tools-16-0/server-tools-16-0-base_search_fuzzy/it/
Currently translated at 100.0% (18 of 18 strings)

Translation: server-tools-18.0/server-tools-18.0-base_search_fuzzy
Translate-URL: https://translation.odoo-community.org/projects/server-tools-18-0/server-tools-18-0-base_search_fuzzy/nl/
@dnplkndll dnplkndll marked this pull request as draft May 20, 2026 23:08
@dnplkndll dnplkndll force-pushed the 19.0-mig-base_search_fuzzy branch 2 times, most recently from 795a7a9 to b027810 Compare May 20, 2026 23:35
Copy link
Copy Markdown

@carlos-lopez-tecnativa carlos-lopez-tecnativa left a comment

Choose a reason for hiding this comment

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

Please squash the administrative commits, and all commits related to the migration can be squashed into a single commit (keeping the pre-commit auto-fix commit separate).

Comment thread base_search_fuzzy/models/trgm_index.py Outdated
@dnplkndll dnplkndll force-pushed the 19.0-mig-base_search_fuzzy branch 3 times, most recently from 04150f1 to e66267f Compare May 29, 2026 01:13
@dnplkndll dnplkndll marked this pull request as ready for review May 29, 2026 01:36
Copy link
Copy Markdown

@carlos-lopez-tecnativa carlos-lopez-tecnativa left a comment

Choose a reason for hiding this comment

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

In my previous comment, I suggested squashing the administrative commits, but I noticed that you squashed commits that should not have been squashed and merged them into the previous commit, losing the original author. Please review this and rework the Git history correctly.

You can read this documentation if it helps:
https://github.com/OCA/maintainer-tools/wiki/Merge-commits-in-pull-requests

@dnplkndll
Copy link
Copy Markdown
Contributor Author

In my previous comment, I suggested squashing the administrative commits, but I noticed that you squashed commits that should not have been squashed and merged them into the previous commit, losing the original author. Please review this and rework the Git history correctly.

You can read this documentation if it helps: https://github.com/OCA/maintainer-tools/wiki/Merge-commits-in-pull-requests

thanks I was trying to write a script and looking for something specific.

@dnplkndll dnplkndll force-pushed the 19.0-mig-base_search_fuzzy branch from e66267f to cc307d7 Compare May 29, 2026 20:22
dnplkndll added 2 commits May 29, 2026 16:42
Re-implements the PostgreSQL trigram similarity operator ``%`` using
Odoo 19's ``@operator_optimization`` decorator + ``Domain.custom``.

The 18.0 ``post_load`` hook that mutated
``odoo.osv.expression.TERM_OPERATORS`` and ``SQL_OPERATORS`` no longer
works in 19.0:

- ``SQL_OPERATORS`` moved from ``odoo.osv.expression`` to
  ``odoo.orm.utils`` (no re-export).
- ``TERM_OPERATORS`` is now a rebound copy of
  ``odoo.orm.domains.CONDITION_OPERATORS``; the new ``Domain``
  validator keys off ``CONDITION_OPERATORS`` directly, so mutating
  ``expression.TERM_OPERATORS`` no longer registers the operator.
- The new generic ``Field._condition_to_sql`` does not consult
  ``SQL_OPERATORS`` for unknown operators; an unknown operator like
  ``%`` raises ``NotImplementedError``.

The replacement registers the operator at import time via
``@operator_optimization(['%'])`` and emits the trigram-similarity
predicate through ``Domain.custom(to_sql=...)`` — the supported path
used in core by ``auth_totp``, ``analytic_mixin`` and
``account_tax``. ``post_load`` is dropped from the manifest, and
``hooks.py`` is removed.

Tests assert ``%`` is in ``CONDITION_OPERATORS`` and verify the
emitted SQL contains the field reference + escaped ``%%`` template;
the end-to-end ``pg_trgm`` test is unchanged.
@dnplkndll dnplkndll force-pushed the 19.0-mig-base_search_fuzzy branch from cc307d7 to 7d38cc9 Compare May 29, 2026 20:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:base_search_fuzzy Module base_search_fuzzy series:19.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.