summaryrefslogtreecommitdiff
path: root/addons/web/static/src
diff options
context:
space:
mode:
authorqsm-odoo <qsm@odoo.com>2017-03-06 17:30:52 +0100
committerAaron Bohy <aab@odoo.com>2017-04-11 19:44:38 +0200
commit825cd69dc0494ec340c6e0a0a7a7333aac8401c8 (patch)
treee1cfa34d6d94060e47ad6bfa77d739ffed20ec5f /addons/web/static/src
parent6da2e588b12d90fade841fb15643a8ee5f674609 (diff)
[FIX] web: allow to build a domain from a number
Some views were trying to make fields invisible thanks to `attrs="{'invisible': 1}"`. This is not supposed to be valid as an attrs value is supposed to be a domain and not a number. To make the fields always invisible, use the "invisible" *attribute*. This also allows the client to make the fields invisible without any domain computation. However, to keep supporting those kind of attrs and to be more generic, the Domain class is adapted by this commit to consider numeric domains to be valid (numbers different than 0 are considered "true" domains and 0 is considered a "false" domain).
Diffstat (limited to 'addons/web/static/src')
-rw-r--r--addons/web/static/src/js/core/domain.js7
1 files changed, 4 insertions, 3 deletions
diff --git a/addons/web/static/src/js/core/domain.js b/addons/web/static/src/js/core/domain.js
index be6adf81b57..4749d736f2a 100644
--- a/addons/web/static/src/js/core/domain.js
+++ b/addons/web/static/src/js/core/domain.js
@@ -19,15 +19,16 @@ var Domain = collections.Tree.extend({
* * a boolean where the "true" domain match all records and the
* "false" domain does not match any records.
* * undefined, considered as the false boolean.
+ * * a number, considered as true except 0 considered as false.
* @param {Object} [evalContext] - in case the given domain is a string, an
* evaluation context might be needed
*/
init: function (domain, evalContext) {
this._super.apply(this, arguments);
- if (domain === true || domain === false || domain === undefined) {
- this._data = domain || false;
- } else {
+ if (_.isArray(domain) || _.isString(domain)) {
this._parse(this.normalizeArray(_.clone(this.stringToArray(domain, evalContext))));
+ } else {
+ this._data = !!domain;
}
},