Skip to content

Commit 3b3fdde

Browse files
committed
Merge PR #2831 into 17.0
Signed-off-by dreispt
2 parents 20a6ddf + f1b908b commit 3b3fdde

40 files changed

+11785
-0
lines changed

Diff for: base_name_search_improved/README.rst

+160
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
====================
2+
Improved Name Search
3+
====================
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:fe0fce7aeb356dfbf982cb648994712ec1907ee6ab73a221eee4cda4039e7a33
11+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12+
13+
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
14+
:target: https://odoo-community.org/page/development-status
15+
:alt: Beta
16+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
17+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
18+
:alt: License: AGPL-3
19+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github
20+
:target: https://github.com/OCA/server-tools/tree/17.0/base_name_search_improved
21+
:alt: OCA/server-tools
22+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23+
:target: https://translation.odoo-community.org/projects/server-tools-17-0/server-tools-17-0-base_name_search_improved
24+
:alt: Translate me on Weblate
25+
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/server-tools&target_branch=17.0
27+
:alt: Try me on Runboat
28+
29+
|badge1| |badge2| |badge3| |badge4| |badge5|
30+
31+
Extends the name search feature to use additional, more relaxed matching
32+
methods, and to allow searching into configurable additional record
33+
fields.
34+
35+
The name search is the lookup feature to select a related record. For
36+
example, selecting a Customer on a new Sales order.
37+
38+
For example, typing "john brown" doesn't match "John M. Brown". The
39+
relaxed search also looks up for records containing all the words, so
40+
"John M. Brown" would be a match. It also tolerates words in a different
41+
order, so searching for "brown john" also works.
42+
43+
|image0|
44+
45+
Additionally, an Administrator can configure other fields to also lookup
46+
into. For example, Customers could be additionally searched by City or
47+
Phone number.
48+
49+
|image2|
50+
51+
How it works:
52+
53+
Regular name search is performed, and the additional search logic is
54+
only triggered if not enough results are found. This way, no overhead is
55+
added on searches that would normally yield results.
56+
57+
But if not enough results are found, then additional search methods are
58+
tried. The specific methods used are:
59+
60+
- Try regular search on each of the additional fields
61+
- Try ordered word search on each of the search fields
62+
- Try unordered word search on each of the search fields
63+
64+
All results found are presented in that order, hopefully presenting them
65+
in order of relevance.
66+
67+
.. |image0| image:: https://raw.githubusercontent.com/OCA/server-tools/11.0/base_name_search_improved/images/image0.png
68+
.. |image2| image:: https://raw.githubusercontent.com/OCA/server-tools/11.0/base_name_search_improved/images/image2.png
69+
70+
**Table of contents**
71+
72+
.. contents::
73+
:local:
74+
75+
Configuration
76+
=============
77+
78+
The fuzzy search is automatically enabled on all Models. Note that this
79+
only affects typing in related fields. The regular ``search()``, used in
80+
the top right search box, is not affected.
81+
82+
Additional search fields can be configured at Settings > Technical >
83+
Database > Models, using the "Name Search Fields" field.
84+
85+
|image1|
86+
87+
.. |image1| image:: https://raw.githubusercontent.com/OCA/server-tools/11.0/base_name_search_improved/images/image1.png
88+
89+
Usage
90+
=====
91+
92+
Just type into any related field, such as Customer on a Sale Order.
93+
94+
Known issues / Roadmap
95+
======================
96+
97+
- Also use fuzzy search, such as the Levenshtein distance:
98+
https://www.postgresql.org/docs/9.5/static/fuzzystrmatch.html
99+
- The list of additional fields to search could benefit from caching,
100+
for efficiency.
101+
- This feature could also be implemented for regular ``search`` on the
102+
``name`` field.
103+
- While adding m2o or other related field that also have an improved
104+
name search, that improved name search is not used (while if
105+
name_search is customizend on a module and you add a field of that
106+
model on another model it works ok). Esto por ejemplo es en productos
107+
si agregamos campo "categoría pública" y a categoría pública le
108+
ponemos "parent_id". Entonces vamos a ver que si buscamos por una
109+
categoría padre no busca nada, en vez si hacemos esa lógica en
110+
name_search de modulo si funciona
111+
112+
Bug Tracker
113+
===========
114+
115+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/server-tools/issues>`_.
116+
In case of trouble, please check there if your issue has already been reported.
117+
If you spotted it first, help us to smash it by providing a detailed and welcomed
118+
`feedback <https://github.com/OCA/server-tools/issues/new?body=module:%20base_name_search_improved%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
119+
120+
Do not contact contributors directly about support or help with technical issues.
121+
122+
Credits
123+
=======
124+
125+
Authors
126+
-------
127+
128+
* Daniel Reis
129+
* ADHOC SA
130+
131+
Contributors
132+
------------
133+
134+
- Daniel Reis <https://github.com/dreispt>
135+
- Kitti U. <[email protected]> (migrate to v14)
136+
- Radovan Skolnik <[email protected]>
137+
138+
Other credits
139+
-------------
140+
141+
The development of this module has been financially supported by:
142+
143+
- Odoo Community Association
144+
145+
Maintainers
146+
-----------
147+
148+
This module is maintained by the OCA.
149+
150+
.. image:: https://odoo-community.org/logo.png
151+
:alt: Odoo Community Association
152+
:target: https://odoo-community.org
153+
154+
OCA, or the Odoo Community Association, is a nonprofit organization whose
155+
mission is to support the collaborative development of Odoo features and
156+
promote its widespread use.
157+
158+
This module is part of the `OCA/server-tools <https://github.com/OCA/server-tools/tree/17.0/base_name_search_improved>`_ project on GitHub.
159+
160+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

Diff for: base_name_search_improved/__init__.py

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# © 2016 Daniel Reis
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
3+
from .hooks import uninstall_hook
4+
from . import models

Diff for: base_name_search_improved/__manifest__.py

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# © 2016 Daniel Reis
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
3+
{
4+
"name": "Improved Name Search",
5+
"summary": "Friendlier search when typing in relation fields",
6+
"version": "17.0.1.0.0",
7+
"category": "Uncategorized",
8+
"website": "https://github.com/OCA/server-tools",
9+
"author": "Daniel Reis, Odoo Community Association (OCA), ADHOC SA",
10+
"license": "AGPL-3",
11+
"data": ["views/ir_model_views.xml"],
12+
"depends": ["base"],
13+
"installable": True,
14+
"uninstall_hook": "uninstall_hook",
15+
}

Diff for: base_name_search_improved/hooks.py

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import logging
2+
3+
_logger = logging.getLogger(__name__)
4+
5+
6+
def uninstall_hook(env):
7+
_logger.info("Reverting Patches...")
8+
fields_to_unlink = (
9+
env["ir.model.fields"]
10+
.with_context(_force_unlink=True)
11+
.search([("name", "=", "smart_search")])
12+
)
13+
if fields_to_unlink:
14+
fields_to_unlink.unlink()
15+
_logger.info("Done!")

0 commit comments

Comments
 (0)