diff options
| author | Xavier Dubuc <xdu@odoo.com> | 2021-03-10 16:45:49 +0000 |
|---|---|---|
| committer | Sébastien Theys <seb@odoo.com> | 2021-03-10 16:48:19 +0000 |
| commit | fbdec5fe29827b88ec0d1421f68716e1febefd89 (patch) | |
| tree | afbbc6fd6da16ace2af4c2992678657b814d0197 /addons/mail/static/src/utils/utils.js | |
| parent | f326ba2d14e4fdd811426c6381b7e5bc3c1d657b (diff) | |
[FIX] mail; hr: restore faster and more accurate mention suggestions
The code from v13 used to look for partners in JS before making the RPC, which
was much faster, and also gave better results by returning partners that were
already known and therefore more likely to be selected.
The same logic is reintroduced here, and further improved to take into account
all known partners and sort them according to the likeliness they will be
selected based on various criteria.
task-2413776
closes odoo/odoo#64161
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Co-authored-by: Sébastien Theys <seb@odoo.com>
Diffstat (limited to 'addons/mail/static/src/utils/utils.js')
| -rw-r--r-- | addons/mail/static/src/utils/utils.js | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/addons/mail/static/src/utils/utils.js b/addons/mail/static/src/utils/utils.js index f502fc8f326..2cfaa531f77 100644 --- a/addons/mail/static/src/utils/utils.js +++ b/addons/mail/static/src/utils/utils.js @@ -4,6 +4,7 @@ odoo.define('mail/static/src/utils/utils.js', function (require) { const { delay } = require('web.concurrency'); const { patch: webUtilsPatch, + unaccent, unpatch: webUtilsUnpatch, } = require('web.utils'); @@ -15,6 +16,18 @@ const classPatchMap = new WeakMap(); const eventHandledWeakMap = new WeakMap(); /** + * Returns the given string after cleaning it. The goal of the clean is to give + * more convenient results when comparing it to potential search results, on + * which the clean should also be called before comparing them. + * + * @param {string} searchTerm + * @returns {string} + */ +function cleanSearchTerm(searchTerm) { + return unaccent(searchTerm.toLowerCase()); +} + +/** * Executes the provided functions in order, but with a potential delay between * them if they take too much time. This is done in order to avoid blocking the * main thread for too long. @@ -166,6 +179,7 @@ function unpatchInstanceMethods(Class, patchName) { //------------------------------------------------------------------------------ return { + cleanSearchTerm, executeGracefully, isEventHandled, markEventHandled, |
