diff --git a/src/common.js b/src/common.js index 1aec8fecad..92e1ad6b36 100644 --- a/src/common.js +++ b/src/common.js @@ -2186,6 +2186,13 @@ return Boolean(context[field.split('.')[0]]); } var context_field = context[field]; + if (!~['=', '!='].indexOf(operand) && + ((context_field === null) || + (context_field === undefined) || + (value === null) || + (value === undefined))) { + return; + } if ((context_field && context_field._isAMomentObject) && !value) { if (context_field.isDateTime) { value = Sao.DateTime.min; @@ -2271,8 +2278,9 @@ } else if (domain[0] == 'OR') { return this.eval_domain(domain.slice(1), context, this.or); } else { - return boolop(this.eval_domain(domain[0], context), - this.eval_domain(domain.slice(1), context, boolop)); + return boolop(Boolean(this.eval_domain(domain[0], context)), + Boolean(this.eval_domain(domain.slice(1), context, boolop)) + ); } }, localize_domain: function(domain, field_name, strip_target) { diff --git a/tests/sao.js b/tests/sao.js index bb585e4c7c..9cc8a7540c 100644 --- a/tests/sao.js +++ b/tests/sao.js @@ -2524,10 +2524,10 @@ [ [[['x', '>', 5]], {'x': 6}, true], [[['x', '>', 5]], {'x': 4}, false], - [[['x', '>', null]], {'x': today}, true], - [[['x', '>', null]], {'x': now}, true], - [[['x', '<', today]], {'x': null}, true], - [[['x', '<', now]], {'x': null}, true], + [[['x', '>', null]], {'x': today}, false], + [[['x', '>', null]], {'x': now}, false], + [[['x', '<', today]], {'x': null}, false], + [[['x', '<', now]], {'x': null}, false], [[['x', 'in', [3, 5]]], {'x': 3}, true], [[['x', 'in', [3, 5]]], {'x': 4}, false], [[['x', 'in', [3, 5]]], {'x': [3]}, true],