From 57992c51b5b223d2ecae887f108629dea7698f11 Mon Sep 17 00:00:00 2001 From: Jorge Pinna Puissant Date: Tue, 7 Sep 2021 06:22:19 +0000 Subject: [PATCH] [IMP] web: add archParseBoolean util function This function must be used to parse boolean attributes from archs. If returns false if the attribute is set to "False", "false", "0" or "", true otherwise. Part-of: odoo/odoo#73311 --- addons/web/static/src/views/helpers/utils.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 addons/web/static/src/views/helpers/utils.js diff --git a/addons/web/static/src/views/helpers/utils.js b/addons/web/static/src/views/helpers/utils.js new file mode 100644 index 00000000000..8b0c0ff1ff1 --- /dev/null +++ b/addons/web/static/src/views/helpers/utils.js @@ -0,0 +1,13 @@ +/** @odoo-module **/ + +/** + * Parse the arch to check if is true or false + * If the string is empyt, 0, False or false it's considered as false + * The rest is considered as true + * + * @param {string} str + * @returns {boolean} + */ +export function archParseBoolean(str) { + return str !== "False" && str !== "false" && str !== "0" && str !== ""; +}