[ADD] search_ux: search products and partners by keywords and configurable fields - #441
Open
mav-adhoc wants to merge 1 commit into
Open
[ADD] search_ux: search products and partners by keywords and configurable fields#441mav-adhoc wants to merge 1 commit into
mav-adhoc wants to merge 1 commit into
Conversation
Contributor
mav-adhoc
force-pushed
the
19.0-t-72472-mav
branch
4 times, most recently
from
August 24, 2026 20:05
db55487 to
83980e3
Compare
mav-adhoc
force-pushed
the
19.0-t-72472-mav
branch
from
September 1, 2026 18:39
83980e3 to
a356974
Compare
…rable fields Adds a "search keywords" field on products and partners for aliases and trade names, and a per model configuration to add fields and related sources to the search. It only hooks into the extension points Odoo documents, on the two search surfaces of the backend: name_search on product.template and product.product for the autocomplete (calling super and completing the suggestion list), _search_display_name on res.partner, and _get_view to add the search_extended seam to the free text search of the search views, composing with whatever filter_domain other modules left there. Only those models inherit the mixin, and the extra criteria are built as a single domain resolved in a single query, which runs only when the native search did not fill the limit. The extended search only applies to partial match operators, so an exact search keeps matching exactly, and a related source the user cannot read is skipped instead of raising. The configuration lives on its own model, restricted to the models that inherit the mixin, with a field picker that walks relations, and rejects on save what cannot be sustained: html, binary and non stored fields, wrong paths, group restricted fields and more than five fields per model. Customer specific sources are added from customer modules by inheriting _get_extra_search_domains, without forking this module.
mav-adhoc
force-pushed
the
19.0-t-72472-mav
branch
from
September 3, 2026 16:02
a356974 to
b03b557
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Sustainable replacement for
base_name_search_improved(OCA), on products and partners.Task: https://www.adhoc.inc/odoo/all-tasks/12857/all-tasks/72472
What it does out of the box
product.templateandres.partner, for aliases, nicknames and trade names.How it hooks
product.template,product.productname_search: callssuper()and completes the suggestion list only if the native cascade did not filllimitres.partner_search_display_name: adds the fields to the same declarative domain, no extra query_get_viewappends('search_extended', 'ilike', self)to thefilter_domainof the free text search field, composing with whatever other modules left thereNo
_inherit = "base", no_register_hook, no monkeypatching of the registry. Only those models inherit the mixin, explicitly.Multi word: the term is split and all words must appear, in any order and in any configured field, built as a single domain resolved in a single query.
The seam is injected in
_get_viewand not in XML on purpose:partner_internal_code(75 productive databases) rewrites thatfilter_domainto searchcomplete_nameinstead ofdisplay_name, so a static patch would either be overwritten or would drop itsinternal_codeclause. Verified on a database with it installed: the rendered domain keepscomplete_name,ref,emailandinternal_code, and adds the seam.Two guards worth calling out:
ilike/like. An exact search (=,=ilike) keeps matching exactly instead of leaking partial matches through the keywords.stock.lotrequires the Inventory/User group, so without this guard enabling the lot source would break the product autocomplete for every user without inventory rights.What the consultant configures
Settings > Extended Search, per model: fields to include (model fields, Studio fields and forward paths like
product_tmpl_id.my_field), related sources for products (lots/serials, vendor code, packaging barcodes), minimum characters before triggering (default 3), and archiving to turn it off completely. Fields are picked with the native field selector, which walks relations, so the consultant does not have to know the technical names.It rejects on save, with an explanation: html fields, binary/attachment fields, non stored fields, wrong paths, group restricted fields and more than 5 fields per model (
search_ux.max_fields).Customization
A customer module adds its own source by inheriting a single extension point, without forking:
Test plan
21 tests, green on a fresh 19.0 database with
search_ux,stock,contactsandpartner_internal_codeinstalled:Covered: keywords on the three models, native behaviour untouched without configuration, the extended search not running when the native one fills the limit, multi word in a single query, both surfaces returning the same records, the search views carrying the seam and composing with a rewritten filter_domain, minimum characters, turning it off, exact operators not extended, a source without access being skipped, the received domain being honoured, the extension point, and every rejected configuration.
Known deviations from the spec
Not included on purpose
Typo correction, lot reservation when the product is found by serial, and searching inside html descriptions.