From 9ee9724a10fc5e835d8d42da0e9e83fe687848d8 Mon Sep 17 00:00:00 2001 From: mgh-odoo Date: Mon, 29 Oct 2018 08:42:59 +0000 Subject: [Generic] unaccent search - added unaccent search on POS customer/partner and product - moved unaccent from "mail.utils" to "web.utils" - added more character to make function accurate We might use str.normalize(from ES6) but the problem is str.normalize method can not consider some double characters i.e. accented character when normalized it returns 2 normal characters and normalize method returns single character, so here custom unaccent method is used to normalize the string What we can improve here: We can use str.normalize method and check if string is still have unaccented charaters that we can call our unaccent method but this unaccent method is also working and performing well closes odoo/odoo#27671 --- addons/web/static/tests/core/util_tests.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'addons/web/static/tests/core/util_tests.js') diff --git a/addons/web/static/tests/core/util_tests.js b/addons/web/static/tests/core/util_tests.js index c7158083dcb..3dd0a54b5e3 100644 --- a/addons/web/static/tests/core/util_tests.js +++ b/addons/web/static/tests/core/util_tests.js @@ -55,6 +55,18 @@ QUnit.module('core', {}, function () { assert.strictEqual(is_bin_size('64.2 Кб'), true); }); + QUnit.test('unaccent', function (assert) { + assert.expect(3); + + var singleCharacters = utils.unaccent("ⱮɀꝾƶⱵȥ"); + var doubledCharacters = utils.unaccent("DZDŽꝎꜩꝡƕ"); + var caseSensetiveCharacters = utils.unaccent("ⱮɀꝾƶⱵȥ", true); + + assert.strictEqual("mzgzhz", singleCharacters); + assert.strictEqual("dzdzootzvyhv", doubledCharacters); + assert.strictEqual("MzGzHz", caseSensetiveCharacters); + }); + }); -}); \ No newline at end of file +}); -- cgit v1.2.3