Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
df8bdb1
Renamed module base_trgm_search to base_search_fuzzy, added Unit test…
Jun 24, 2016
0016c70
Fix typo
dreispt Aug 10, 2016
48c8e9d
OCA Transbot updated translations from Transifex
oca-transbot Aug 14, 2016
e8b75f5
Migrated base_search_fuzzy to v9
serpentcs-dev1 Dec 26, 2016
4449eca
OCA Transbot updated translations from Transifex
oca-transbot Jan 14, 2017
f293187
base_search_fuzzy: Upgrade to v10 * Rename manifest * Update openerp …
lasley Feb 1, 2017
55d08a3
OCA Transbot updated translations from Transifex
oca-transbot May 1, 2017
526ea06
Typos
gdgellatly Sep 11, 2017
04a296a
OCA Transbot updated translations from Transifex
oca-transbot Dec 2, 2017
6859ffa
base_search_fuzzy: Migration to 11.0
cubells Jun 11, 2018
e22486b
Update base_search_fuzzy.pot
oca-travis Jun 17, 2018
b725b70
base_search_fuzzy: Migration to 12.0
ernestotejeda Jan 10, 2019
1aa25b8
Update base_search_fuzzy.pot
oca-travis Jan 14, 2019
83bd136
Update translation files
oca-transbot Jan 27, 2019
b467348
icon.png
OCA-git-bot Apr 3, 2019
244094f
Translated using Weblate (Portuguese)
pedrocs-exo Aug 14, 2019
eb61f3e
Translated using Weblate (Portuguese (Brazil))
Aug 30, 2019
818d993
Translated using Weblate (Chinese (Simplified))
liweijie0812 Aug 31, 2019
10e0fd6
base_search_fuzzy: black, isort
Mar 25, 2020
3080ee1
base_search_fuzzy: Migration to 13.0
Mar 25, 2020
0adb326
Update translation files
oca-transbot Apr 15, 2020
5480eb1
Eficent -> ForgeFlow
MiquelRForgeFlow Sep 30, 2020
473d7ca
base_search_fuzzy: black, isort, prettier
AreebSiddiqiIR May 28, 2021
07137e8
base_search_fuzzy: Migration to 14.0
AreebSiddiqiIR May 28, 2021
85318a7
base_search_fuzzy: correct patching, remove similarity order
Aug 19, 2021
0c63b91
Update translation files
oca-transbot Aug 20, 2021
2e82fd6
Translated using Weblate (Portuguese (Brazil))
Feb 1, 2022
b7c3b41
base_search_fuzzy: black, isort, prettier
Shide Mar 11, 2022
1dc2709
base_search_fuzzy: Migration to 15.0
Shide Mar 11, 2022
8ced236
Translated using Weblate (Spanish (Argentina))
ibuioli Mar 15, 2022
175e9e8
[MIG] base_search_fuzzy: Migrated to v16
Nikul-OSI Jan 20, 2023
8094463
Update translation files
weblate Mar 3, 2023
6926f5b
Translated using Weblate (Italian)
mymage Mar 23, 2023
f6f5fa4
Translated using Weblate (Slovenian)
sysadminmatmoz Apr 11, 2023
20a9ba2
[UPD] Update base_search_fuzzy.pot
Jun 7, 2023
6844a00
Update translation files
weblate Jun 7, 2023
5e36f3b
Translated using Weblate (Spanish)
Ivorra78 Aug 27, 2023
fbe2aae
Translated using Weblate (Italian)
mymage Jan 3, 2024
62acb01
[IMP] base_search_fuzzy: pre-commit auto fixes
nguyenminhchien Jan 19, 2024
e1403b9
[MIG] base_search_fuzzy: Migration to 17.0
nguyenminhchien Jan 23, 2024
17e54a9
[UPD] Update base_search_fuzzy.pot
Apr 7, 2025
876434f
[BOT] post-merge updates
OCA-git-bot Apr 7, 2025
ad2a7e1
[IMP] base_search_fuzzy: pre-commit auto fixes
map-240221 Apr 28, 2025
979e34d
[MIG] base_search_fuzzy: Migration to 18.0
map-240221 Apr 28, 2025
88d0b5e
[UPD] Update base_search_fuzzy.pot
May 21, 2025
bc7b98d
[BOT] post-merge updates
OCA-git-bot May 21, 2025
a1fd9da
Translated using Weblate (Dutch)
bosd May 14, 2026
0251f5d
[IMP] base_search_fuzzy - add support of translatable fields
yvaucher Oct 23, 2025
a08a872
[UPD] Update base_search_fuzzy.pot
Jun 5, 2026
5c17ec4
[BOT] post-merge updates
OCA-git-bot Jun 5, 2026
d877e69
Update translation files
weblate Jun 5, 2026
59b5d50
Translated using Weblate (Italian)
mymage Jun 8, 2026
99e1e0b
[IMP] base_search_fuzzy: pre-commit auto fixes
dnplkndll May 20, 2026
63d1654
[MIG] base_search_fuzzy: Migration to 19.0
dnplkndll May 20, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
158 changes: 158 additions & 0 deletions base_search_fuzzy/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
.. image:: https://odoo-community.org/readme-banner-image
:target: https://odoo-community.org/get-involved?utm_source=readme
:alt: Odoo Community Association

============
Fuzzy Search
============

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:34ba1dcdd338caeda33db67951dc8ba37243ebf42c273bf00f27b800a2134abe
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github
:target: https://github.com/OCA/server-tools/tree/19.0/base_search_fuzzy
:alt: OCA/server-tools
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/server-tools-19-0/server-tools-19-0-base_search_fuzzy
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/server-tools&target_branch=19.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This addon provides the ability to create GIN or GiST indexes of char
and text fields and also to use the search operator % in search domains.
Currently this module doesn't change the backend search or anything
else. It provides only the possibility to perform the fuzzy search for
external addons.

**Table of contents**

.. contents::
:local:

Installation
============

1. The PostgreSQL extension ``pg_trgm`` should be available. In debian
based distribution you have to install the postgresql-contrib module.
2. Install the ``pg_trgm`` extension to your database or give your
postgresql user the ``SUPERUSER`` right (this allows the odoo module
to install the extension to the database).

Configuration
=============

If the odoo module is installed:

1. You can define ``GIN`` and ``GiST`` indexes for char and text via
Settings -> Database Structure -> Trigram Index. The index name will
automatically created for new entries.

Usage
=====

1. You can create an index for the name field of res.partner.

2. In the search you can use:

``self.env['res.partner'].search([('name', '%', 'Jon Smit')])``

3. In this example the function will return positive result for John
Smith or John Smit.

4. You can tweak the number of strings to be returned by adjusting the
set limit (default: 0.3). NB: Currently you have to set the limit by
executing the following SQL statement:

``self.env.cr.execute("SELECT set_limit(0.2);")``

For further questions read the Documentation of the
`pg_trgm <https://www.postgresql.org/docs/current/static/pgtrgm.html>`__
module.

Usage with demo data
--------------------

There are some demo data that allow you to test functionally this module
if you are in a **demo** database. The steps are the following:

1. Go to *Contacts* and type the text **Jon Smith** or **Smith John** in
the search box and select **Search Display Name for: ...**
2. You will see two contacts, and they are the ones with display names
**John Smith** and **John Smizz**.

Known issues / Roadmap
======================

- Modify the general search parts (e.g. in tree view or many2one fields)
- Add better order by handling
- This module will not be necessary from version 16 (`[IMP] Better
handling of indexes
#83015 <https://github.com/odoo/odoo/pull/83015>`__)

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/server-tools/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/server-tools/issues/new?body=module:%20base_search_fuzzy%0Aversion:%2019.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
-------

* bloopark systems GmbH & Co. KG
* ForgeFlow
* Serpent CS

Contributors
------------

- Christoph Giesel <https://github.com/christophlsa>
- Jordi Ballester <jordi.ballester@forgeflow.com>
- Serpent Consulting Services Pvt. Ltd. <support@serpentcs.com>
- Dave Lasley <dave@laslabs.com>
- `Tecnativa <https://www.tecnativa.com>`__:

- Vicent Cubells
- Ernesto Tejeda

- teodoralexandru@nexterp.ro 2020 NextERP SRL.
- Daniel Reis <dreis@opensourceintegrators.com>
- Nikul Chaudhary <nchaudhary@opensourceintegrators.com>
- Nguyen Minh Chien <chien@trobz.com>

Maintainers
-----------

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/server-tools <https://github.com/OCA/server-tools/tree/19.0/base_search_fuzzy>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
5 changes: 5 additions & 0 deletions base_search_fuzzy/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Copyright 2016 ForgeFlow S.L.
# Copyright 2016 Serpent Consulting Services Pvt. Ltd.
# Copyright 2020 NextERP SRL.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import models
19 changes: 19 additions & 0 deletions base_search_fuzzy/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2016 ForgeFlow S.L.
# Copyright 2016 Serpent Consulting Services Pvt. Ltd.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "Fuzzy Search",
"summary": "Fuzzy search with the PostgreSQL trigram extension",
"category": "Uncategorized",
"version": "19.0.1.0.0",
"website": "https://github.com/OCA/server-tools",
"author": "bloopark systems GmbH & Co. KG, "
"ForgeFlow, "
"Serpent CS, "
"Odoo Community Association (OCA)",
"license": "AGPL-3",
"depends": ["base"],
"data": ["views/trgm_index.xml", "security/ir.model.access.csv"],
"demo": ["demo/res_partner_demo.xml", "demo/TrgmIndex_demo.xml"],
"installable": True,
}
7 changes: 7 additions & 0 deletions base_search_fuzzy/demo/TrgmIndex_demo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<odoo>
<record id="trgm_index_gin_partner_name" model="trgm.index">
<field name="field_id" ref="base.field_res_partner__name" />
<field name="index_type">gin</field>
Comment on lines +3 to +4

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>

<field name="lang">en_US</field>
</record>
</odoo>
23 changes: 23 additions & 0 deletions base_search_fuzzy/demo/res_partner_demo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<odoo>
<record id="res_partner_John_Smith" model="res.partner">
<field name="name">John Smith</field>
</record>

<record id="res_partner_John_Smizz" model="res.partner">
<field name="name">John Smizz</field>
</record>

<record id="res_partner_Linus_Torvalds" model="res.partner">
<field name="name">Linus Torvalds</field>
</record>

<record id="view_res_partner_filter" model="ir.ui.view">
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_res_partner_filter" />
<field name="arch" type="xml">
<field name="name" position="after">
<field name="complete_name" operator="%" />
</field>
</field>
</record>
</odoo>
124 changes: 124 additions & 0 deletions base_search_fuzzy/i18n/am.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * base_search_fuzzy
#
# Translators:
# OCA Transbot <transbot@odoo-community.org>, 2017
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0c\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-01-14 04:21+0000\n"
"PO-Revision-Date: 2017-01-14 04:21+0000\n"
"Last-Translator: OCA Transbot <transbot@odoo-community.org>, 2017\n"
"Language-Team: Amharic (https://www.transifex.com/oca/teams/23907/am/)\n"
"Language: am\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"

#. module: base_search_fuzzy
#: model:ir.model.fields,help:base_search_fuzzy.field_trgm_index__index_type
msgid ""
"Cite from PostgreSQL documentation: GIN indexes are the preferred text "
"search index type.See: https://www.postgresql.org/docs/current/textsearch-"
"indexes.html"
msgstr ""

#. module: base_search_fuzzy
#: model:ir.model.fields,field_description:base_search_fuzzy.field_trgm_index__create_uid
msgid "Created by"
msgstr "Creado por"

#. module: base_search_fuzzy
#: model:ir.model.fields,field_description:base_search_fuzzy.field_trgm_index__create_date
msgid "Created on"
msgstr "Creado en"

#. module: base_search_fuzzy
#: model:ir.model.fields,field_description:base_search_fuzzy.field_trgm_index__display_name
msgid "Display Name"
msgstr ""

#. module: base_search_fuzzy
#: model:ir.model.fields,field_description:base_search_fuzzy.field_trgm_index__field_id
msgid "Field"
msgstr ""

#. module: base_search_fuzzy
#: model:ir.model.fields.selection,name:base_search_fuzzy.selection__trgm_index__index_type__gin
msgid "GIN"
msgstr ""

#. module: base_search_fuzzy
#: model:ir.model.fields.selection,name:base_search_fuzzy.selection__trgm_index__index_type__gist
msgid "GiST"
msgstr ""

#. module: base_search_fuzzy
#: model:ir.model.fields,field_description:base_search_fuzzy.field_trgm_index__id
msgid "ID"
msgstr "ID"

#. module: base_search_fuzzy
#: model:ir.model.fields,field_description:base_search_fuzzy.field_trgm_index__index_name
msgid "Index Name"
msgstr ""

#. module: base_search_fuzzy
#: model:ir.model.fields,field_description:base_search_fuzzy.field_trgm_index__index_type
msgid "Index Type"
msgstr ""

#. module: base_search_fuzzy
#: model:ir.model.fields,field_description:base_search_fuzzy.field_trgm_index__lang
msgid "Language"
msgstr ""

#. module: base_search_fuzzy
#: model:ir.model.fields,field_description:base_search_fuzzy.field_trgm_index__write_uid
msgid "Last Updated by"
msgstr "Última actualización por"

#. module: base_search_fuzzy
#: model:ir.model.fields,field_description:base_search_fuzzy.field_trgm_index__write_date
msgid "Last Updated on"
msgstr "Última actualización en"

#. module: base_search_fuzzy
#: model:ir.model.fields,field_description:base_search_fuzzy.field_trgm_index__smart_search
msgid "Smart Search"
msgstr ""

#. module: base_search_fuzzy
#: model:ir.model.fields,help:base_search_fuzzy.field_trgm_index__index_name
msgid ""
"The index name is automatically generated like fieldname_indextype_idx. If "
"the index already exists and the index is located in the same table then "
"this index is reused. If the index is located in another table then a number "
"is added at the end of the index name."
msgstr ""

#. module: base_search_fuzzy
#. odoo-python
#: code:addons/base_search_fuzzy/models/trgm_index.py:0
msgid "The pg_trgm extension does not exists or cannot be installed."
msgstr ""

#. module: base_search_fuzzy
#: model:ir.actions.act_window,name:base_search_fuzzy.trgm_index_action
#: model:ir.model,name:base_search_fuzzy.model_trgm_index
#: model:ir.ui.menu,name:base_search_fuzzy.trgm_index_menu
msgid "Trigram Index"
msgstr ""

#. module: base_search_fuzzy
#: model:ir.model.fields,help:base_search_fuzzy.field_trgm_index__field_id
msgid "You can either select a field of type \"text\" or \"char\"."
msgstr ""

#. module: base_search_fuzzy
#: model:ir.model.fields,help:base_search_fuzzy.field_trgm_index__lang
msgid "You will need one index per installed language."
msgstr ""
Loading
Loading