diff options
| author | Aaron Bohy <aab@odoo.com> | 2021-02-09 09:25:15 +0000 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2021-02-11 09:20:26 +0000 |
| commit | 885932ae8e31905e08b79141a445933b6afc9f15 (patch) | |
| tree | 1a6c56abae64b65322e62e06f8f1f60c1313c4b4 /addons/web/static/src/js/core | |
| parent | 95aebcbc8051f71762724149f6b20f3501485cdd (diff) | |
[FIX] web: keep null/false/true strings in domains
Before this commit, occurences of 'null', 'true' and 'false'
strings as autocomplete values in the search view were replaced
respectively by None, True and False.
Fixes #65743
closes odoo/odoo#65900
X-original-commit: 74311c753e7286c27b83dca2b598e040ed9e586f
Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Diffstat (limited to 'addons/web/static/src/js/core')
| -rw-r--r-- | addons/web/static/src/js/core/domain.js | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/addons/web/static/src/js/core/domain.js b/addons/web/static/src/js/core/domain.js index 3e3fd4e4201..dbf2b18eb40 100644 --- a/addons/web/static/src/js/core/domain.js +++ b/addons/web/static/src/js/core/domain.js @@ -234,15 +234,26 @@ var Domain = collections.Tree.extend({ * representation of the Python prefix-array representation of this domain. * * @static - * @param {Array|string} domain + * @param {Array|string|undefined} domain * @returns {string} */ arrayToString: function (domain) { if (_.isString(domain)) return domain; - return JSON.stringify(domain || []) - .replace(/null/g, "None") - .replace(/false/g, "False") - .replace(/true/g, "True"); + const parts = (domain || []).map(part => { + if (_.isArray(part)) { // e.g. ['name', 'ilike', 'foo'] or ['is_active', '=', true] + return "[" + part.map(c => { + switch (c) { + case null: return "None"; + case true: return "True"; + case false: return "False"; + default: return JSON.stringify(c); + } + }).join(',') + "]"; + } else { // e.g. '|' or '&' + return JSON.stringify(part); + } + }); + return "[" + parts.join(',') + "]"; }, /** * Converts a string representation of the Python prefix-array |
