Skip to content

Commit

Permalink
[IMP] web: add archParseBoolean util function
Browse files Browse the repository at this point in the history
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#73311
  • Loading branch information
jpp-odoo authored and aab-odoo committed Sep 7, 2021
1 parent 1fd54ee commit 57992c5
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions addons/web/static/src/views/helpers/utils.js
Original file line number Diff line number Diff line change
@@ -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 !== "";
}

0 comments on commit 57992c5

Please sign in to comment.