Skip to content

Commit 21480b4

Browse files
authored
Merge pull request OCA#608 from OCA/13.0
Syncing from upstream OCA/server-tools (13.0)
2 parents e1828e9 + 8084db2 commit 21480b4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+10031
-1
lines changed

base_search_fuzzy/README.rst

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
============
2+
Fuzzy Search
3+
============
4+
5+
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
6+
!! This file is generated by oca-gen-addon-readme !!
7+
!! changes will be overwritten. !!
8+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
9+
10+
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
11+
:target: https://odoo-community.org/page/development-status
12+
:alt: Beta
13+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
14+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
15+
:alt: License: AGPL-3
16+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github
17+
:target: https://github.com/OCA/server-tools/tree/13.0/base_search_fuzzy
18+
:alt: OCA/server-tools
19+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
20+
:target: https://translation.odoo-community.org/projects/server-tools-13-0/server-tools-13-0-base_search_fuzzy
21+
:alt: Translate me on Weblate
22+
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
23+
:target: https://runbot.odoo-community.org/runbot/149/13.0
24+
:alt: Try me on Runbot
25+
26+
|badge1| |badge2| |badge3| |badge4| |badge5|
27+
28+
This addon provides the ability to create GIN or GiST indexes of char and text
29+
fields and also to use the search operator `%` in search domains. Currently
30+
this module doesn't change the backend search or anything else. It provides
31+
only the possibility to perform the fuzzy search for external addons.
32+
33+
**Table of contents**
34+
35+
.. contents::
36+
:local:
37+
38+
Installation
39+
============
40+
41+
#. The PostgreSQL extension ``pg_trgm`` should be available. In debian based
42+
distribution you have to install the `postgresql-contrib` module.
43+
#. Install the ``pg_trgm`` extension to your database or give your postgresql
44+
user the ``SUPERUSER`` right (this allows the odoo module to install the
45+
extension to the database).
46+
47+
Configuration
48+
=============
49+
50+
If the odoo module is installed:
51+
52+
#. You can define ``GIN`` and ``GiST`` indexes for `char` and `text` via
53+
`Settings -> Database Structure -> Trigram Index`. The index name will
54+
automatically created for new entries.
55+
56+
Usage
57+
=====
58+
59+
#. You can create an index for the `name` field of `res.partner`.
60+
#. In the search you can use:
61+
62+
``self.env['res.partner'].search([('name', '%', 'Jon Miller)])``
63+
64+
#. In this example the function will return positive result for `John Miller`
65+
or `John Mill`.
66+
67+
#. You can tweak the number of strings to be returned by adjusting the set
68+
limit (default: 0.3). NB: Currently you have to set the limit by executing
69+
the following SQL statement:
70+
71+
``self.env.cr.execute("SELECT set_limit(0.2);")``
72+
73+
#. Another interesting feature is the use of ``similarity(column, 'text')``
74+
function in the ``order`` parameter to order by similarity. This module just
75+
contains a basic implementation which doesn't perform validations and has to
76+
start with this function. For example you can define the function as
77+
followed:
78+
79+
``similarity(%s.name, 'John Mil') DESC" % self.env['res.partner']._table``
80+
81+
For further questions read the Documentation of the
82+
`pg_trgm <https://www.postgresql.org/docs/current/static/pgtrgm.html>`_ module.
83+
84+
85+
Usage with demo data
86+
====================
87+
88+
There are some demo data that allow you to test functionally this module
89+
if you are in a **demo** database. The steps are the following:
90+
91+
#. Go to *Contacts* and type the text **Jon Smith** or **Smith John** in
92+
the search box and select **Search Display Name for: ...**
93+
#. You will see two contacts, and they are the ones with display names
94+
**John Smith** and **John Smizz**.
95+
96+
Known issues / Roadmap
97+
======================
98+
99+
* Modify the general search parts (e.g. in tree view or many2one fields)
100+
* Add better `order by` handling
101+
102+
Bug Tracker
103+
===========
104+
105+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/server-tools/issues>`_.
106+
In case of trouble, please check there if your issue has already been reported.
107+
If you spotted it first, help us smashing it by providing a detailed and welcomed
108+
`feedback <https://github.com/OCA/server-tools/issues/new?body=module:%20base_search_fuzzy%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
109+
110+
Do not contact contributors directly about support or help with technical issues.
111+
112+
Credits
113+
=======
114+
115+
Authors
116+
~~~~~~~
117+
118+
* bloopark systems GmbH & Co. KG
119+
* Eficent
120+
* Serpent CS
121+
122+
Contributors
123+
~~~~~~~~~~~~
124+
125+
* Christoph Giesel <https://github.com/christophlsa>
126+
* Jordi Ballester <[email protected]>
127+
* Serpent Consulting Services Pvt. Ltd. <[email protected]>
128+
* Dave Lasley <[email protected]>
129+
130+
* `Tecnativa <https://www.tecnativa.com>`_:
131+
132+
* Vicent Cubells
133+
* Ernesto Tejeda
134+
135+
Maintainers
136+
~~~~~~~~~~~
137+
138+
This module is maintained by the OCA.
139+
140+
.. image:: https://odoo-community.org/logo.png
141+
:alt: Odoo Community Association
142+
:target: https://odoo-community.org
143+
144+
OCA, or the Odoo Community Association, is a nonprofit organization whose
145+
mission is to support the collaborative development of Odoo features and
146+
promote its widespread use.
147+
148+
This module is part of the `OCA/server-tools <https://github.com/OCA/server-tools/tree/13.0/base_search_fuzzy>`_ project on GitHub.
149+
150+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

base_search_fuzzy/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Copyright 2016 Eficent Business and IT Consulting Services S.L.
2+
# Copyright 2016 Serpent Consulting Services Pvt. Ltd.
3+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
4+
from . import models

base_search_fuzzy/__manifest__.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Copyright 2016 Eficent Business and IT Consulting Services S.L.
2+
# Copyright 2016 Serpent Consulting Services Pvt. Ltd.
3+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
4+
{
5+
"name": "Fuzzy Search",
6+
"summary": "Fuzzy search with the PostgreSQL trigram extension",
7+
"category": "Uncategorized",
8+
"version": "13.0.1.0.0",
9+
"website": "https://github.com/OCA/server-tools",
10+
"author": "bloopark systems GmbH & Co. KG, "
11+
"Eficent, "
12+
"Serpent CS, "
13+
"Odoo Community Association (OCA)",
14+
"license": "AGPL-3",
15+
"depends": ["base"],
16+
"data": ["views/trgm_index.xml", "security/ir.model.access.csv"],
17+
"demo": ["demo/res_partner_demo.xml", "demo/TrgmIndex_demo.xml"],
18+
"installable": True,
19+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<odoo>
3+
<record id="trgm_index_gin_partner_name" model="trgm.index">
4+
<field name="field_id" ref="base.field_res_partner__name" />
5+
<field name="index_type">gin</field>
6+
</record>
7+
</odoo>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<odoo>
3+
<record id="res_partner_John_Smith" model="res.partner">
4+
<field name="name">John Smith</field>
5+
</record>
6+
<record id="res_partner_John_Smizz" model="res.partner">
7+
<field name="name">John Smizz</field>
8+
</record>
9+
<record id="res_partner_Linus_Torvalds" model="res.partner">
10+
<field name="name">Linus Torvalds</field>
11+
</record>
12+
<record id="view_res_partner_filter" model="ir.ui.view">
13+
<field name="model">res.partner</field>
14+
<field name="inherit_id" ref="base.view_res_partner_filter" />
15+
<field name="arch" type="xml">
16+
<field name="name" position="after">
17+
<field name="display_name" operator="%" />
18+
</field>
19+
</field>
20+
</record>
21+
</odoo>

base_search_fuzzy/i18n/am.po

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
# Translation of Odoo Server.
2+
# This file contains the translation of the following modules:
3+
# * base_search_fuzzy
4+
#
5+
# Translators:
6+
# OCA Transbot <[email protected]>, 2017
7+
msgid ""
8+
msgstr ""
9+
"Project-Id-Version: Odoo Server 10.0c\n"
10+
"Report-Msgid-Bugs-To: \n"
11+
"POT-Creation-Date: 2017-01-14 04:21+0000\n"
12+
"PO-Revision-Date: 2017-01-14 04:21+0000\n"
13+
"Last-Translator: OCA Transbot <[email protected]>, 2017\n"
14+
"Language-Team: Amharic (https://www.transifex.com/oca/teams/23907/am/)\n"
15+
"Language: am\n"
16+
"MIME-Version: 1.0\n"
17+
"Content-Type: text/plain; charset=UTF-8\n"
18+
"Content-Transfer-Encoding: \n"
19+
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
20+
21+
#. module: base_search_fuzzy
22+
#: model:ir.model.fields,help:base_search_fuzzy.field_trgm_index__index_type
23+
msgid ""
24+
"Cite from PostgreSQL documentation: \"As a rule of thumb, a GIN index is "
25+
"faster to search than a GiST index, but slower to build or update; so GIN is "
26+
"better suited for static data and GiST for often-updated data.\""
27+
msgstr ""
28+
29+
#. module: base_search_fuzzy
30+
#: model:ir.model.fields,field_description:base_search_fuzzy.field_trgm_index__create_uid
31+
msgid "Created by"
32+
msgstr "Creado por"
33+
34+
#. module: base_search_fuzzy
35+
#: model:ir.model.fields,field_description:base_search_fuzzy.field_trgm_index__create_date
36+
msgid "Created on"
37+
msgstr "Creado en"
38+
39+
#. module: base_search_fuzzy
40+
#: model:ir.model.fields,field_description:base_search_fuzzy.field_trgm_index__display_name
41+
msgid "Display Name"
42+
msgstr ""
43+
44+
#. module: base_search_fuzzy
45+
#: model:ir.model.fields,field_description:base_search_fuzzy.field_trgm_index__field_id
46+
msgid "Field"
47+
msgstr ""
48+
49+
#. module: base_search_fuzzy
50+
#: selection:trgm.index,index_type:0
51+
msgid "GIN"
52+
msgstr ""
53+
54+
#. module: base_search_fuzzy
55+
#: selection:trgm.index,index_type:0
56+
msgid "GiST"
57+
msgstr ""
58+
59+
#. module: base_search_fuzzy
60+
#: model:ir.model.fields,field_description:base_search_fuzzy.field_trgm_index__id
61+
msgid "ID"
62+
msgstr "ID"
63+
64+
#. module: base_search_fuzzy
65+
#: model:ir.model.fields,field_description:base_search_fuzzy.field_trgm_index__index_name
66+
msgid "Index Name"
67+
msgstr ""
68+
69+
#. module: base_search_fuzzy
70+
#: model:ir.model.fields,field_description:base_search_fuzzy.field_trgm_index__index_type
71+
msgid "Index Type"
72+
msgstr ""
73+
74+
#. module: base_search_fuzzy
75+
#: code:addons/base_search_fuzzy/models/ir_model.py:39
76+
#, python-format
77+
msgid "Invalid field %r in domain term %r"
78+
msgstr ""
79+
80+
#. module: base_search_fuzzy
81+
#: model:ir.model.fields,field_description:base_search_fuzzy.field_trgm_index____last_update
82+
msgid "Last Modified on"
83+
msgstr ""
84+
85+
#. module: base_search_fuzzy
86+
#: model:ir.model.fields,field_description:base_search_fuzzy.field_trgm_index__write_uid
87+
msgid "Last Updated by"
88+
msgstr "Última actualización por"
89+
90+
#. module: base_search_fuzzy
91+
#: model:ir.model.fields,field_description:base_search_fuzzy.field_trgm_index__write_date
92+
msgid "Last Updated on"
93+
msgstr "Última actualización en"
94+
95+
#. module: base_search_fuzzy
96+
#: model:ir.model,name:base_search_fuzzy.model_ir_model
97+
msgid "Models"
98+
msgstr ""
99+
100+
#. module: base_search_fuzzy
101+
#: model:ir.model.fields,help:base_search_fuzzy.field_trgm_index__index_name
102+
msgid ""
103+
"The index name is automatically generated like fieldname_indextype_idx. If "
104+
"the index already exists and the index is located in the same table then "
105+
"this index is reused. If the index is located in another table then a number "
106+
"is added at the end of the index name."
107+
msgstr ""
108+
109+
#. module: base_search_fuzzy
110+
#: code:addons/base_search_fuzzy/models/trgm_index.py:126
111+
#, python-format
112+
msgid "The pg_trgm extension does not exists or cannot be installed."
113+
msgstr ""
114+
115+
#. module: base_search_fuzzy
116+
#: model:ir.actions.act_window,name:base_search_fuzzy.trgm_index_action
117+
#: model:ir.model,name:base_search_fuzzy.model_trgm_index
118+
#: model:ir.ui.menu,name:base_search_fuzzy.trgm_index_menu
119+
#: model_terms:ir.ui.view,arch_db:base_search_fuzzy.trgm_index_view_form
120+
#: model_terms:ir.ui.view,arch_db:base_search_fuzzy.trgm_index_view_tree
121+
msgid "Trigram Index"
122+
msgstr ""
123+
124+
#. module: base_search_fuzzy
125+
#: model:ir.model.fields,help:base_search_fuzzy.field_trgm_index__field_id
126+
msgid "You can either select a field of type \"text\" or \"char\"."
127+
msgstr ""

0 commit comments

Comments
 (0)