Skip to content

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

Merged
OCA-git-bot merged 54 commits into
OCA:19.0from
ledoent:19.0-mig-base_search_fuzzy
Jun 13, 2026
Merged

[19.0][MIG] base_search_fuzzy: Migration to 19.0#3620
OCA-git-bot merged 54 commits into
OCA:19.0from
ledoent:19.0-mig-base_search_fuzzy

Conversation

@dnplkndll

@dnplkndll dnplkndll commented May 20, 2026

Copy link
Copy Markdown
Contributor

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

Includes #3429 (translatable-fields trigram support) and its follow-up history, replayed as 18.0 commits with original authorship.

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.
  • The % predicate is emitted parenthesized: a translatable field renders as the bare JSON accessor name->>'en_US', and % binds tighter than ->>, so the unparenthesized form fails with operator does not exist: jsonb ->> boolean. On 18.0 that wrapping comes from odoo/odoo#232993 (still open); on 19.0 the operator is emitted by this module's own Domain.custom, so the parentheses make this PR self-contained with no dependency on that core PR.
  • The generated translatable index name is folded to lowercase: CREATE INDEX folds the unquoted identifier, but get_not_used_index compares it literally against pg_indexes, so the mixed-case lang component (name_en_US_gin_idx) never matched.

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. Core's translatable trigram support covers only its own like/ilike path; the % similarity equivalent for translatable fields is what #3429 (included here) provides.

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/
@dnplkndll
dnplkndll force-pushed the 19.0-mig-base_search_fuzzy branch 2 times, most recently from cc307d7 to 7d38cc9 Compare May 29, 2026 20:42

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM, just a non-blocking comment: I noticed this commit: 4644318

It has an unusual title, and I would expect it to have a description such as:

[IMP] base_search_fuzzy: pre-commit auto fixes

But anyway, this is not a blocker.

@pedrobaeza Could you please review this?

@pedrobaeza

Copy link
Copy Markdown
Member

Yes, please follow migration guideline

https://github.com/OCA/maintainer-tools/wiki/Migration-to-version-19.0

and please include #3429

@dnplkndll
dnplkndll force-pushed the 19.0-mig-base_search_fuzzy branch 2 times, most recently from 5d1de24 to b2e924e Compare June 11, 2026 12:26
@dnplkndll

Copy link
Copy Markdown
Contributor Author

@pedrobaeza I got the pick.

@pedrobaeza

Copy link
Copy Markdown
Member

/ocabot migration base_search_fuzzy

@OCA-git-bot OCA-git-bot added this to the 19.0 milestone Jun 11, 2026
@OCA-git-bot OCA-git-bot mentioned this pull request Jun 11, 2026
43 tasks
Comment on lines +3 to +4
<field name="field_id" ref="base.field_res_partner__name" />
<field name="index_type">gin</field>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Please define a language to prevent the field from being empty if it is required at the view level.
Image

Suggested change
<field name="field_id" ref="base.field_res_partner__name" />
<field name="index_type">gin</field>
<field name="field_id" ref="base.field_res_partner__name" />
<field name="index_type">gin</field>
<field name="lang">en_US</field>

- Register the trigram `%` operator via @operator_optimization +
  Domain.custom: the 18.0 post_load hook mutating
  osv.expression TERM_OPERATORS/SQL_OPERATORS no longer registers
  operators in 19.0 (hooks.py removed).
- Parenthesize the `%` operand so translatable (jsonb) fields work:
  `%` binds tighter than `->>`. 18.0 relies on the still-open
  odoo/odoo#232993; 19.0 is self-contained.
- Lowercase the generated translatable index name: Postgres folds
  unquoted identifiers, the pg_indexes lookup compares literally.
- Add an end-to-end translatable fuzzy-search test.
@dnplkndll
dnplkndll force-pushed the 19.0-mig-base_search_fuzzy branch from b2e924e to 63d1654 Compare June 12, 2026 01:45

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM

TT58599

@pedrobaeza pedrobaeza left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

/ocabot merge nobump

@OCA-git-bot

Copy link
Copy Markdown
Contributor

This PR looks fantastic, let's merge it!
Prepared branch 19.0-ocabot-merge-pr-3620-by-pedrobaeza-bump-nobump, awaiting test results.

@OCA-git-bot
OCA-git-bot merged commit 0d30696 into OCA:19.0 Jun 13, 2026
7 checks passed
@OCA-git-bot

Copy link
Copy Markdown
Contributor

Congratulations, your PR was merged at 6c96f8e. Thanks a lot for contributing to OCA. ❤️

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.