diff --git a/base_name_search_improved/README.rst b/base_name_search_improved/README.rst new file mode 100644 index 000000000..02d5fd46f --- /dev/null +++ b/base_name_search_improved/README.rst @@ -0,0 +1,141 @@ +==================== +Improved Name Search +==================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/licence-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/11.0/base_name_search_improved + :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-11-0/server-tools-11-0-base_name_search_improved + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/149/11.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Extends the name search feature to use additional, more relaxed +matching methods, and to allow searching into configurable additional +record fields. + +The name search is the lookup feature to select a related record. +For example, selecting a Customer on a new Sales order. + +For example, typing "john brown" doesn't match "John M. Brown". +The relaxed search also looks up for records containing all the words, +so "John M. Brown" would be a match. +It also tolerates words in a different order, so searching +for "brown john" also works. + +.. figure:: https://raw.githubusercontent.com/OCA/server-tools/11.0/base_name_search_improved/images/image0.png + +Additionally, an Administrator can configure other fields to also lookup into. +For example, Customers could be additionally searched by City or Phone number. + +.. figure:: https://raw.githubusercontent.com/OCA/server-tools/11.0/base_name_search_improved/images/image2.png + +How it works: + +Regular name search is performed, and the additional search logic is only +triggered if not enough results are found. +This way, no overhead is added on searches that would normally yield results. + +But if not enough results are found, then additional search methods are tried. +The specific methods used are: + +- Try regular search on each of the additional fields +- Try ordered word search on each of the search fields +- Try unordered word search on each of the search fields + +All results found are presented in that order, +hopefully presenting them in order of relevance. + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +The fuzzy search is automatically enabled on all Models. +Note that this only affects typing in related fields. +The regular ``search()``, used in the top right search box, is not affected. + +Additional search fields can be configured at Settings > Technical > Database > Models, +using the "Name Search Fields" field. + +.. figure:: https://raw.githubusercontent.com/OCA/server-tools/11.0/base_name_search_improved/images/image1.png + :alt: Name Search Fields + :width: 600 px + +Usage +===== + +Just type into any related field, such as Customer on a Sale Order. + +Known issues / Roadmap +====================== + +* Also use fuzzy search, such as the Levenshtein distance: + https://www.postgresql.org/docs/9.5/static/fuzzystrmatch.html +* The list of additional fields to search could benefit from caching, for efficiency. +* This feature could also be implemented for regular ``search`` on the ``name`` field. + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Daniel Reis + +Contributors +~~~~~~~~~~~~ + +* Daniel Reis + +Other credits +~~~~~~~~~~~~~ + +The development of this module has been financially supported by: + +* Odoo Community Association + +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 `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/base_name_search_improved/__init__.py b/base_name_search_improved/__init__.py new file mode 100644 index 000000000..a7c34e431 --- /dev/null +++ b/base_name_search_improved/__init__.py @@ -0,0 +1,3 @@ +# Copyright 2016 Daniel Reis +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from . import models diff --git a/base_name_search_improved/__manifest__.py b/base_name_search_improved/__manifest__.py new file mode 100644 index 000000000..cc1db964c --- /dev/null +++ b/base_name_search_improved/__manifest__.py @@ -0,0 +1,18 @@ +# Copyright 2016 Daniel Reis +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +{ + 'name': 'Improved Name Search', + 'summary': 'Friendlier search when typing in relation fields', + 'version': '11.0.1.0.0', + 'category': 'Uncategorized', + 'website': 'https://github.com/OCA/server-tools', + 'author': 'Daniel Reis, Odoo Community Association (OCA)', + 'license': 'AGPL-3', + 'data': [ + 'views/ir_model_views.xml', + ], + 'depends': [ + 'base', + ], + 'installable': True, +} diff --git a/base_name_search_improved/i18n/base_name_search_improved.pot b/base_name_search_improved/i18n/base_name_search_improved.pot new file mode 100644 index 000000000..c7307f136 --- /dev/null +++ b/base_name_search_improved/i18n/base_name_search_improved.pot @@ -0,0 +1,25 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_name_search_improved +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: base_name_search_improved +#: model:ir.model,name:base_name_search_improved.model_ir_model +msgid "Models" +msgstr "" + +#. module: base_name_search_improved +#: model:ir.model.fields,field_description:base_name_search_improved.field_ir_model_name_search_ids +msgid "Name Search Fields" +msgstr "" + diff --git a/base_name_search_improved/i18n/ca.po b/base_name_search_improved/i18n/ca.po new file mode 100644 index 000000000..14b514ca6 --- /dev/null +++ b/base_name_search_improved/i18n/ca.po @@ -0,0 +1,30 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_name_search_improved +# +# Translators: +# Marc Tormo i Bochaca , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-04-19 17:59+0000\n" +"PO-Revision-Date: 2018-07-04 10:03+0000\n" +"Last-Translator: mtbochaca \n" +"Language-Team: Catalan (https://www.transifex.com/oca/teams/23907/ca/)\n" +"Language: ca\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" +"X-Generator: Weblate 3.0.1\n" + +#. module: base_name_search_improved +#: model:ir.model,name:base_name_search_improved.model_ir_model +msgid "Models" +msgstr "Models " + +#. module: base_name_search_improved +#: model:ir.model.fields,field_description:base_name_search_improved.field_ir_model_name_search_ids +msgid "Name Search Fields" +msgstr "Camps de cerca de nom" diff --git a/base_name_search_improved/i18n/de.po b/base_name_search_improved/i18n/de.po new file mode 100644 index 000000000..8eaba33dd --- /dev/null +++ b/base_name_search_improved/i18n/de.po @@ -0,0 +1,30 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_name_search_improved +# +# Translators: +# OCA Transbot , 2016 +# Rudolf Schnapka , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-03-04 07:38+0000\n" +"PO-Revision-Date: 2017-03-04 07:38+0000\n" +"Last-Translator: Rudolf Schnapka , 2017\n" +"Language-Team: German (https://www.transifex.com/oca/teams/23907/de/)\n" +"Language: de\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_name_search_improved +#: model:ir.model,name:base_name_search_improved.model_ir_model +msgid "Models" +msgstr "Modelle" + +#. module: base_name_search_improved +#: model:ir.model.fields,field_description:base_name_search_improved.field_ir_model_name_search_ids +msgid "Name Search Fields" +msgstr "Felder für Bezeichnungssuche" diff --git a/base_name_search_improved/i18n/en.po b/base_name_search_improved/i18n/en.po new file mode 100644 index 000000000..b79ff8fe4 --- /dev/null +++ b/base_name_search_improved/i18n/en.po @@ -0,0 +1,26 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_name_search_improved +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-06-17 02:42+0000\n" +"PO-Revision-Date: 2016-06-17 02:42+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: base_name_search_improved +#: model:ir.model,name:base_name_search_improved.model_ir_model +msgid "Models" +msgstr "Models" + +#. module: base_name_search_improved +#: field:ir.model,name_search_ids:0 +msgid "Name Search Fields" +msgstr "Name Search Fields" diff --git a/base_name_search_improved/i18n/es.po b/base_name_search_improved/i18n/es.po new file mode 100644 index 000000000..3ba5380db --- /dev/null +++ b/base_name_search_improved/i18n/es.po @@ -0,0 +1,30 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_name_search_improved +# +# Translators: +# OCA Transbot , 2016 +# Pedro M. Baeza , 2016 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-12-23 21:53+0000\n" +"PO-Revision-Date: 2016-12-23 21:53+0000\n" +"Last-Translator: Pedro M. Baeza , 2016\n" +"Language-Team: Spanish (https://www.transifex.com/oca/teams/23907/es/)\n" +"Language: es\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_name_search_improved +#: model:ir.model,name:base_name_search_improved.model_ir_model +msgid "Models" +msgstr "Modelos" + +#. module: base_name_search_improved +#: model:ir.model.fields,field_description:base_name_search_improved.field_ir_model_name_search_ids +msgid "Name Search Fields" +msgstr "Campos de la búsqueda por nombre" diff --git a/base_name_search_improved/i18n/es_ES.po b/base_name_search_improved/i18n/es_ES.po new file mode 100644 index 000000000..c81901e8c --- /dev/null +++ b/base_name_search_improved/i18n/es_ES.po @@ -0,0 +1,30 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_name_search_improved +# +# Translators: +# Fernando Lara , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-02-16 10:39+0000\n" +"PO-Revision-Date: 2017-02-16 10:39+0000\n" +"Last-Translator: Fernando Lara , 2017\n" +"Language-Team: Spanish (Spain) (https://www.transifex.com/oca/teams/23907/" +"es_ES/)\n" +"Language: es_ES\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_name_search_improved +#: model:ir.model,name:base_name_search_improved.model_ir_model +msgid "Models" +msgstr "Modelos" + +#. module: base_name_search_improved +#: model:ir.model.fields,field_description:base_name_search_improved.field_ir_model_name_search_ids +msgid "Name Search Fields" +msgstr "Campos de búsqueda de nombres" diff --git a/base_name_search_improved/i18n/eu.po b/base_name_search_improved/i18n/eu.po new file mode 100644 index 000000000..2f990b371 --- /dev/null +++ b/base_name_search_improved/i18n/eu.po @@ -0,0 +1,29 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_name_search_improved +# +# Translators: +# Esther Martín Menéndez , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-02-22 00:48+0000\n" +"PO-Revision-Date: 2017-02-22 00:48+0000\n" +"Last-Translator: Esther Martín Menéndez , 2017\n" +"Language-Team: Basque (https://www.transifex.com/oca/teams/23907/eu/)\n" +"Language: eu\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_name_search_improved +#: model:ir.model,name:base_name_search_improved.model_ir_model +msgid "Models" +msgstr "Models" + +#. module: base_name_search_improved +#: model:ir.model.fields,field_description:base_name_search_improved.field_ir_model_name_search_ids +msgid "Name Search Fields" +msgstr "" diff --git a/base_name_search_improved/i18n/fi.po b/base_name_search_improved/i18n/fi.po new file mode 100644 index 000000000..ac254a1fa --- /dev/null +++ b/base_name_search_improved/i18n/fi.po @@ -0,0 +1,29 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_name_search_improved +# +# Translators: +# Jarmo Kortetjärvi , 2016 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-09-21 00:47+0000\n" +"PO-Revision-Date: 2016-09-21 00:47+0000\n" +"Last-Translator: Jarmo Kortetjärvi , 2016\n" +"Language-Team: Finnish (https://www.transifex.com/oca/teams/23907/fi/)\n" +"Language: fi\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_name_search_improved +#: model:ir.model,name:base_name_search_improved.model_ir_model +msgid "Models" +msgstr "Mallit" + +#. module: base_name_search_improved +#: model:ir.model.fields,field_description:base_name_search_improved.field_ir_model_name_search_ids +msgid "Name Search Fields" +msgstr "" diff --git a/base_name_search_improved/i18n/fr.po b/base_name_search_improved/i18n/fr.po new file mode 100644 index 000000000..1b73b660b --- /dev/null +++ b/base_name_search_improved/i18n/fr.po @@ -0,0 +1,29 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_name_search_improved +# +# Translators: +# OCA Transbot , 2016 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-06-17 02:42+0000\n" +"PO-Revision-Date: 2016-06-17 02:42+0000\n" +"Last-Translator: OCA Transbot , 2016\n" +"Language-Team: French (https://www.transifex.com/oca/teams/23907/fr/)\n" +"Language: fr\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_name_search_improved +#: model:ir.model,name:base_name_search_improved.model_ir_model +msgid "Models" +msgstr "Modèles" + +#. module: base_name_search_improved +#: model:ir.model.fields,field_description:base_name_search_improved.field_ir_model_name_search_ids +msgid "Name Search Fields" +msgstr "" diff --git a/base_name_search_improved/i18n/hr.po b/base_name_search_improved/i18n/hr.po new file mode 100644 index 000000000..ce443ddaa --- /dev/null +++ b/base_name_search_improved/i18n/hr.po @@ -0,0 +1,30 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_name_search_improved +# +# Translators: +# Bole , 2016 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-09-21 00:47+0000\n" +"PO-Revision-Date: 2016-09-21 00:47+0000\n" +"Last-Translator: Bole , 2016\n" +"Language-Team: Croatian (https://www.transifex.com/oca/teams/23907/hr/)\n" +"Language: hr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n" +"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n" + +#. module: base_name_search_improved +#: model:ir.model,name:base_name_search_improved.model_ir_model +msgid "Models" +msgstr "Modeli" + +#. module: base_name_search_improved +#: model:ir.model.fields,field_description:base_name_search_improved.field_ir_model_name_search_ids +msgid "Name Search Fields" +msgstr "" diff --git a/base_name_search_improved/i18n/hr_HR.po b/base_name_search_improved/i18n/hr_HR.po new file mode 100644 index 000000000..553139381 --- /dev/null +++ b/base_name_search_improved/i18n/hr_HR.po @@ -0,0 +1,31 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_name_search_improved +# +# Translators: +# Bole , 2016 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-09-21 00:47+0000\n" +"PO-Revision-Date: 2016-09-21 00:47+0000\n" +"Last-Translator: Bole , 2016\n" +"Language-Team: Croatian (Croatia) (https://www.transifex.com/oca/teams/23907/" +"hr_HR/)\n" +"Language: hr_HR\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n" +"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n" + +#. module: base_name_search_improved +#: model:ir.model,name:base_name_search_improved.model_ir_model +msgid "Models" +msgstr "Modeli" + +#. module: base_name_search_improved +#: model:ir.model.fields,field_description:base_name_search_improved.field_ir_model_name_search_ids +msgid "Name Search Fields" +msgstr "" diff --git a/base_name_search_improved/i18n/it.po b/base_name_search_improved/i18n/it.po new file mode 100644 index 000000000..bcf08bb20 --- /dev/null +++ b/base_name_search_improved/i18n/it.po @@ -0,0 +1,29 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_name_search_improved +# +# Translators: +# Paolo Valier , 2016 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-06-17 02:42+0000\n" +"PO-Revision-Date: 2016-06-17 02:42+0000\n" +"Last-Translator: Paolo Valier , 2016\n" +"Language-Team: Italian (https://www.transifex.com/oca/teams/23907/it/)\n" +"Language: it\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_name_search_improved +#: model:ir.model,name:base_name_search_improved.model_ir_model +msgid "Models" +msgstr "Modelli" + +#. module: base_name_search_improved +#: model:ir.model.fields,field_description:base_name_search_improved.field_ir_model_name_search_ids +msgid "Name Search Fields" +msgstr "" diff --git a/base_name_search_improved/i18n/nb_NO.po b/base_name_search_improved/i18n/nb_NO.po new file mode 100644 index 000000000..f4c9c2b0b --- /dev/null +++ b/base_name_search_improved/i18n/nb_NO.po @@ -0,0 +1,30 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_name_search_improved +# +# Translators: +# Imre Kristoffer Eilertsen , 2016 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-12-17 02:07+0000\n" +"PO-Revision-Date: 2016-12-17 02:07+0000\n" +"Last-Translator: Imre Kristoffer Eilertsen , 2016\n" +"Language-Team: Norwegian Bokmål (Norway) (https://www.transifex.com/oca/" +"teams/23907/nb_NO/)\n" +"Language: nb_NO\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_name_search_improved +#: model:ir.model,name:base_name_search_improved.model_ir_model +msgid "Models" +msgstr "Modeller" + +#. module: base_name_search_improved +#: model:ir.model.fields,field_description:base_name_search_improved.field_ir_model_name_search_ids +msgid "Name Search Fields" +msgstr "" diff --git a/base_name_search_improved/i18n/nl.po b/base_name_search_improved/i18n/nl.po new file mode 100644 index 000000000..1e1c338e6 --- /dev/null +++ b/base_name_search_improved/i18n/nl.po @@ -0,0 +1,29 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_name_search_improved +# +# Translators: +# lfreeke , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-04-19 17:59+0000\n" +"PO-Revision-Date: 2017-04-19 17:59+0000\n" +"Last-Translator: lfreeke , 2017\n" +"Language-Team: Dutch (https://www.transifex.com/oca/teams/23907/nl/)\n" +"Language: nl\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_name_search_improved +#: model:ir.model,name:base_name_search_improved.model_ir_model +msgid "Models" +msgstr "Modellen" + +#. module: base_name_search_improved +#: model:ir.model.fields,field_description:base_name_search_improved.field_ir_model_name_search_ids +msgid "Name Search Fields" +msgstr "" diff --git a/base_name_search_improved/i18n/pt_BR.po b/base_name_search_improved/i18n/pt_BR.po new file mode 100644 index 000000000..42b30c3b3 --- /dev/null +++ b/base_name_search_improved/i18n/pt_BR.po @@ -0,0 +1,31 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_name_search_improved +# +# Translators: +# OCA Transbot , 2016 +# Armando Vulcano Junior , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-10-28 11:05+0000\n" +"PO-Revision-Date: 2017-10-28 11:05+0000\n" +"Last-Translator: Armando Vulcano Junior , 2017\n" +"Language-Team: Portuguese (Brazil) (https://www.transifex.com/oca/" +"teams/23907/pt_BR/)\n" +"Language: pt_BR\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_name_search_improved +#: model:ir.model,name:base_name_search_improved.model_ir_model +msgid "Models" +msgstr "Modelos" + +#. module: base_name_search_improved +#: model:ir.model.fields,field_description:base_name_search_improved.field_ir_model_name_search_ids +msgid "Name Search Fields" +msgstr "Campos de pesquisa de nome" diff --git a/base_name_search_improved/i18n/sl.po b/base_name_search_improved/i18n/sl.po new file mode 100644 index 000000000..f8f078056 --- /dev/null +++ b/base_name_search_improved/i18n/sl.po @@ -0,0 +1,30 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_name_search_improved +# +# Translators: +# OCA Transbot , 2016 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-12-17 02:07+0000\n" +"PO-Revision-Date: 2016-12-17 02:07+0000\n" +"Last-Translator: OCA Transbot , 2016\n" +"Language-Team: Slovenian (https://www.transifex.com/oca/teams/23907/sl/)\n" +"Language: sl\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n" +"%100==4 ? 2 : 3);\n" + +#. module: base_name_search_improved +#: model:ir.model,name:base_name_search_improved.model_ir_model +msgid "Models" +msgstr "Modeli" + +#. module: base_name_search_improved +#: model:ir.model.fields,field_description:base_name_search_improved.field_ir_model_name_search_ids +msgid "Name Search Fields" +msgstr "Polja iskanja po imenu" diff --git a/base_name_search_improved/i18n/tr.po b/base_name_search_improved/i18n/tr.po new file mode 100644 index 000000000..854b5d71b --- /dev/null +++ b/base_name_search_improved/i18n/tr.po @@ -0,0 +1,30 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_name_search_improved +# +# Translators: +# OCA Transbot , 2016 +# Ahmet Altinisik , 2016 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-12-29 03:39+0000\n" +"PO-Revision-Date: 2016-12-29 03:39+0000\n" +"Last-Translator: Ahmet Altinisik , 2016\n" +"Language-Team: Turkish (https://www.transifex.com/oca/teams/23907/tr/)\n" +"Language: tr\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_name_search_improved +#: model:ir.model,name:base_name_search_improved.model_ir_model +msgid "Models" +msgstr "Modeller" + +#. module: base_name_search_improved +#: model:ir.model.fields,field_description:base_name_search_improved.field_ir_model_name_search_ids +msgid "Name Search Fields" +msgstr "İsim Arama Alanları" diff --git a/base_name_search_improved/i18n/tr_TR.po b/base_name_search_improved/i18n/tr_TR.po new file mode 100644 index 000000000..60be7063a --- /dev/null +++ b/base_name_search_improved/i18n/tr_TR.po @@ -0,0 +1,30 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_name_search_improved +# +# Translators: +# Ozge Altinisik , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-01-07 04:03+0000\n" +"PO-Revision-Date: 2017-01-07 04:03+0000\n" +"Last-Translator: Ozge Altinisik , 2017\n" +"Language-Team: Turkish (Turkey) (https://www.transifex.com/oca/teams/23907/" +"tr_TR/)\n" +"Language: tr_TR\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=1; plural=0;\n" + +#. module: base_name_search_improved +#: model:ir.model,name:base_name_search_improved.model_ir_model +msgid "Models" +msgstr "Tipler" + +#. module: base_name_search_improved +#: model:ir.model.fields,field_description:base_name_search_improved.field_ir_model_name_search_ids +msgid "Name Search Fields" +msgstr "" diff --git a/base_name_search_improved/i18n/zh_CN.po b/base_name_search_improved/i18n/zh_CN.po new file mode 100644 index 000000000..36cc56f4d --- /dev/null +++ b/base_name_search_improved/i18n/zh_CN.po @@ -0,0 +1,30 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_name_search_improved +# +# Translators: +# Jeffery Chen Fan , 2016 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-12-17 02:07+0000\n" +"PO-Revision-Date: 2016-12-17 02:07+0000\n" +"Last-Translator: Jeffery Chen Fan , 2016\n" +"Language-Team: Chinese (China) (https://www.transifex.com/oca/teams/23907/" +"zh_CN/)\n" +"Language: zh_CN\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=1; plural=0;\n" + +#. module: base_name_search_improved +#: model:ir.model,name:base_name_search_improved.model_ir_model +msgid "Models" +msgstr "模型" + +#. module: base_name_search_improved +#: model:ir.model.fields,field_description:base_name_search_improved.field_ir_model_name_search_ids +msgid "Name Search Fields" +msgstr "" diff --git a/base_name_search_improved/images/image0.png b/base_name_search_improved/images/image0.png new file mode 100644 index 000000000..f6bbf6459 Binary files /dev/null and b/base_name_search_improved/images/image0.png differ diff --git a/base_name_search_improved/images/image1.png b/base_name_search_improved/images/image1.png new file mode 100644 index 000000000..855dbb1a2 Binary files /dev/null and b/base_name_search_improved/images/image1.png differ diff --git a/base_name_search_improved/images/image2.png b/base_name_search_improved/images/image2.png new file mode 100644 index 000000000..ef5ecac43 Binary files /dev/null and b/base_name_search_improved/images/image2.png differ diff --git a/base_name_search_improved/models/__init__.py b/base_name_search_improved/models/__init__.py new file mode 100644 index 000000000..c201f735b --- /dev/null +++ b/base_name_search_improved/models/__init__.py @@ -0,0 +1,3 @@ +# Copyright 2016 Daniel Reis +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from . import ir_model diff --git a/base_name_search_improved/models/ir_model.py b/base_name_search_improved/models/ir_model.py new file mode 100644 index 000000000..0b5baaac4 --- /dev/null +++ b/base_name_search_improved/models/ir_model.py @@ -0,0 +1,80 @@ +# Copyright 2016 Daniel Reis +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import models, fields, api, tools + +# Extended name search is only used on some operators +ALLOWED_OPS = {'ilike', 'like'} + + +@tools.ormcache(skiparg=0) +def _get_rec_names(self): + "List of fields to search into" + model = self.env['ir.model'].search( + [('model', '=', self._name)]) + rec_name = [self._rec_name] if bool(self._rec_name) else [] + other_names = model.name_search_ids.mapped('name') + return rec_name + other_names + + +def _extend_name_results(self, domain, results, limit): + result_count = len(results) + if result_count < limit: + domain += [('id', 'not in', [x[0] for x in results])] + recs = self.search(domain, limit=limit - result_count) + results.extend(recs.name_get()) + return results + + +class IrModel(models.Model): + _inherit = 'ir.model' + + name_search_ids = fields.Many2many( + 'ir.model.fields', + string='Name Search Fields') + + @api.model_cr + def _register_hook(self): + + def make_name_search(): + + @api.model + def name_search(self, name='', args=None, + operator='ilike', limit=100): + # Perform standard name search + res = name_search.origin( + self, name=name, args=args, operator=operator, + limit=limit) + enabled = self.env.context.get('name_search_extended', True) + # Perform extended name search + # Note: Empty name causes error on + # Customer->More->Portal Access Management + if name and enabled and operator in ALLOWED_OPS: + # Support a list of fields to search on + all_names = _get_rec_names(self) + base_domain = args or [] + # Try regular search on each additional search field + for rec_name in all_names[1:]: + domain = [(rec_name, operator, name)] + res = _extend_name_results( + self, base_domain + domain, res, limit) + # Try ordered word search on each of the search fields + for rec_name in all_names: + domain = [ + (rec_name, operator, name.replace(' ', '%'))] + res = _extend_name_results( + self, base_domain + domain, res, limit) + # Try unordered word search on each of the search fields + for rec_name in all_names: + domain = [(rec_name, operator, x) + for x in name.split() if x] + res = _extend_name_results( + self, base_domain + domain, res, limit) + return res + return name_search + + for model in self.sudo().search(self.ids or []): + Model = self.env.get(model.model) + if Model is not None: + Model._patch_method('name_search', make_name_search()) + return super(IrModel, self)._register_hook() diff --git a/base_name_search_improved/readme/CONFIGURE.rst b/base_name_search_improved/readme/CONFIGURE.rst new file mode 100644 index 000000000..e4d666e8b --- /dev/null +++ b/base_name_search_improved/readme/CONFIGURE.rst @@ -0,0 +1,10 @@ +The fuzzy search is automatically enabled on all Models. +Note that this only affects typing in related fields. +The regular ``search()``, used in the top right search box, is not affected. + +Additional search fields can be configured at Settings > Technical > Database > Models, +using the "Name Search Fields" field. + +.. figure:: https://raw.githubusercontent.com/OCA/server-tools/11.0/base_name_search_improved/images/image1.png + :alt: Name Search Fields + :width: 600 px diff --git a/base_name_search_improved/readme/CONTRIBUTORS.rst b/base_name_search_improved/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..3b7e3d4cb --- /dev/null +++ b/base_name_search_improved/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Daniel Reis diff --git a/base_name_search_improved/readme/CREDITS.rst b/base_name_search_improved/readme/CREDITS.rst new file mode 100644 index 000000000..10db89c68 --- /dev/null +++ b/base_name_search_improved/readme/CREDITS.rst @@ -0,0 +1,3 @@ +The development of this module has been financially supported by: + +* Odoo Community Association diff --git a/base_name_search_improved/readme/DESCRIPTION.rst b/base_name_search_improved/readme/DESCRIPTION.rst new file mode 100644 index 000000000..a35c57e46 --- /dev/null +++ b/base_name_search_improved/readme/DESCRIPTION.rst @@ -0,0 +1,35 @@ +Extends the name search feature to use additional, more relaxed +matching methods, and to allow searching into configurable additional +record fields. + +The name search is the lookup feature to select a related record. +For example, selecting a Customer on a new Sales order. + +For example, typing "john brown" doesn't match "John M. Brown". +The relaxed search also looks up for records containing all the words, +so "John M. Brown" would be a match. +It also tolerates words in a different order, so searching +for "brown john" also works. + +.. figure:: https://raw.githubusercontent.com/OCA/server-tools/11.0/base_name_search_improved/images/image0.png + +Additionally, an Administrator can configure other fields to also lookup into. +For example, Customers could be additionally searched by City or Phone number. + +.. figure:: https://raw.githubusercontent.com/OCA/server-tools/11.0/base_name_search_improved/images/image2.png + +How it works: + +Regular name search is performed, and the additional search logic is only +triggered if not enough results are found. +This way, no overhead is added on searches that would normally yield results. + +But if not enough results are found, then additional search methods are tried. +The specific methods used are: + +- Try regular search on each of the additional fields +- Try ordered word search on each of the search fields +- Try unordered word search on each of the search fields + +All results found are presented in that order, +hopefully presenting them in order of relevance. diff --git a/base_name_search_improved/readme/ROADMAP.rst b/base_name_search_improved/readme/ROADMAP.rst new file mode 100644 index 000000000..ecb7b4128 --- /dev/null +++ b/base_name_search_improved/readme/ROADMAP.rst @@ -0,0 +1,4 @@ +* Also use fuzzy search, such as the Levenshtein distance: + https://www.postgresql.org/docs/9.5/static/fuzzystrmatch.html +* The list of additional fields to search could benefit from caching, for efficiency. +* This feature could also be implemented for regular ``search`` on the ``name`` field. diff --git a/base_name_search_improved/readme/USAGE.rst b/base_name_search_improved/readme/USAGE.rst new file mode 100644 index 000000000..049b6284a --- /dev/null +++ b/base_name_search_improved/readme/USAGE.rst @@ -0,0 +1 @@ +Just type into any related field, such as Customer on a Sale Order. diff --git a/base_name_search_improved/static/description/icon.png b/base_name_search_improved/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/base_name_search_improved/static/description/icon.png differ diff --git a/base_name_search_improved/tests/__init__.py b/base_name_search_improved/tests/__init__.py new file mode 100644 index 000000000..ac09dbe92 --- /dev/null +++ b/base_name_search_improved/tests/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2016 Daniel Reis +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import test_name_search diff --git a/base_name_search_improved/tests/test_name_search.py b/base_name_search_improved/tests/test_name_search.py new file mode 100644 index 000000000..0ce407d8f --- /dev/null +++ b/base_name_search_improved/tests/test_name_search.py @@ -0,0 +1,53 @@ +# Copyright 2016 Daniel Reis +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo.tests.common import TransactionCase, at_install, post_install + + +@at_install(False) +@post_install(True) +class NameSearchCase(TransactionCase): + + def setUp(self): + super(NameSearchCase, self).setUp() + phone_field = self.env.ref('base.field_res_partner_phone') + model_partner = self.env.ref('base.model_res_partner') + model_partner.name_search_ids = phone_field + self.Partner = self.env['res.partner'] + self.partner1 = self.Partner.create( + {'name': 'Luigi Verconti', + 'customer': True, + 'phone': '+351 555 777 333'}) + self.partner2 = self.Partner.create( + {'name': 'Ken Shabby', + 'customer': True, + 'phone': '+351 555 333 777'}) + self.partner3 = self.Partner.create( + {'name': 'Johann Gambolputty of Ulm', + 'supplier': True, + 'phone': '+351 777 333 555'}) + + def test_RelevanceOrderedResults(self): + """Return results ordered by relevance""" + res = self.Partner.name_search('555 777') + self.assertEqual( + res[0][0], self.partner1.id, + 'Match full string honoring spaces') + self.assertEqual( + res[1][0], self.partner2.id, + 'Match words honoring order of appearance') + self.assertEqual( + res[2][0], self.partner3.id, + 'Match all words, regardless of order of appearance') + + def test_NameSearchMustMatchAllWords(self): + """Must Match All Words""" + res = self.Partner.name_search('ulm 555 777') + self.assertFalse(res) + + def test_MustHonorDomain(self): + """Must also honor a provided Domain""" + res = self.Partner.name_search('+351', args=[('supplier', '=', True)]) + gambulputty = self.partner3.id + self.assertEqual(len(res), 1) + self.assertEqual(res[0][0], gambulputty) diff --git a/base_name_search_improved/views/ir_model_views.xml b/base_name_search_improved/views/ir_model_views.xml new file mode 100644 index 000000000..7759f0bc3 --- /dev/null +++ b/base_name_search_improved/views/ir_model_views.xml @@ -0,0 +1,21 @@ + + + + + + + Add Name Searchable to Models + ir.model + + + + + + + + +