[19.0][MIG] base_search_fuzzy: Migration to 19.0 - #3620
Conversation
…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/
cc307d7 to
7d38cc9
Compare
carlos-lopez-tecnativa
left a comment
There was a problem hiding this comment.
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?
|
Yes, please follow migration guideline https://github.com/OCA/maintainer-tools/wiki/Migration-to-version-19.0 and please include #3429 |
7d38cc9 to
b812116
Compare
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. 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/
Currently translated at 100.0% (19 of 19 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/it/
5d1de24 to
b2e924e
Compare
|
@pedrobaeza I got the pick. |
|
/ocabot migration base_search_fuzzy |
| <field name="field_id" ref="base.field_res_partner__name" /> | ||
| <field name="index_type">gin</field> |
There was a problem hiding this comment.
Please define a language to prevent the field from being empty if it is required at the view level.

| <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.
b2e924e to
63d1654
Compare
|
This PR looks fantastic, let's merge it! |
|
Congratulations, your PR was merged at 6c96f8e. Thanks a lot for contributing to OCA. ❤️ |
Port of
base_search_fuzzyfrom 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
post_loadhook mutatedodoo.osv.expression.TERM_OPERATORS/SQL_OPERATORSto register the trigram%operator. That path is gone in 19.0 (SQL_OPERATORSmoved toodoo.orm.utils; theDomainvalidator keys offodoo.orm.domains.CONDITION_OPERATORS;Field._condition_to_sqlraisesNotImplementedErrorfor unknown operators). Re-implemented by registering at import time via@operator_optimization(['%'])and emitting the predicate throughDomain.custom(to_sql=...).post_load+hooks.pyremoved.%predicate is emitted parenthesized: a translatable field renders as the bare JSON accessorname->>'en_US', and%binds tighter than->>, so the unparenthesized form fails withoperator 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 ownDomain.custom, so the parentheses make this PR self-contained with no dependency on that core PR.CREATE INDEXfolds the unquoted identifier, butget_not_used_indexcompares it literally againstpg_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 declarativeindex='trigram'field attribute (fields_textual.pycondition_to_sqlprefilter, incl. translatable jsonb fields). Core does not expose a fuzzy%similarity domain operator (%is absent fromCONDITION_OPERATORS; noword_similarity/set_limitin 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 ownlike/ilikepath; the%similarity equivalent for translatable fields is what #3429 (included here) provides.