[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/
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/
795a7a9 to
b027810
Compare
carlos-lopez-tecnativa
left a comment
There was a problem hiding this comment.
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).
04150f1 to
e66267f
Compare
carlos-lopez-tecnativa
left a comment
There was a problem hiding this comment.
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. |
e66267f to
cc307d7
Compare
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.
cc307d7 to
7d38cc9
Compare
Port of
base_search_fuzzyfrom 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_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.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. 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,'$.*')::textinodoo/tools/sql.py), so the module needs no special handling. The round-trip index test usesres.partner.ref(plain text); the translatable-field test asserts WHERE-clause generation only.