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; } }, diff --git a/addons/web/static/test/core/domain_tests.js b/addons/web/static/test/core/domain_tests.js index 70b6e72589f..001eae2d6b9 100644 --- a/addons/web/static/test/core/domain_tests.js +++ b/addons/web/static/test/core/domain_tests.js @@ -51,5 +51,12 @@ QUnit.module('core', {}, function () { assert.ok(new Domain(['!', ['a', '=', 3]]).compute(fields)); assert.ok(new Domain(['!', ['group_method','=','count']]).compute(fields)); }); + + QUnit.test("domains initialized with a number", function (assert) { + assert.expect(2); + + assert.ok(new Domain(1).compute({})); + assert.notOk(new Domain(0).compute({})); + }); }); });