summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/framework
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2017-03-24 17:57:29 +0100
committerChristophe Simonis <chs@odoo.com>2017-03-24 17:57:29 +0100
commit70b770d62e53e55075daef20674a7efaaf85655c (patch)
tree2e00377304a89fe5c00e3e8da50323bf45a8afa7 /addons/web/static/src/js/framework
parentfa02b798377da3a1c14fddbacfc81b626d862283 (diff)
parent8376f538b568c7a679db414bbb2379c66a78cff0 (diff)
[MERGE] forward port branch 9.0 up to 8376f538b56
Diffstat (limited to 'addons/web/static/src/js/framework')
-rw-r--r--addons/web/static/src/js/framework/pyeval.js44
1 files changed, 37 insertions, 7 deletions
diff --git a/addons/web/static/src/js/framework/pyeval.js b/addons/web/static/src/js/framework/pyeval.js
index d0708bdf356..0430aee9274 100644
--- a/addons/web/static/src/js/framework/pyeval.js
+++ b/addons/web/static/src/js/framework/pyeval.js
@@ -850,31 +850,61 @@ function eval_contexts (contexts, evaluation_context) {
function eval_domains (domains, evaluation_context) {
evaluation_context = _.extend(pycontext(), evaluation_context || {});
var result_domain = [];
+ // Normalize only if the first domain is the array ["|"] or ["!"]
+ var need_normalization = (
+ domains.length > 0 &&
+ domains[0].length === 1 &&
+ (domains[0][0] === "|" || domains[0][0] === "!")
+ );
_(domains).each(function (domain) {
if (_.isString(domain)) {
// wrap raw strings in domain
domain = { __ref: 'domain', __debug: domain };
}
+ var domain_array_to_combine;
switch(domain.__ref) {
case 'domain':
evaluation_context.context = evaluation_context;
- result_domain.push.apply(
- result_domain, py.eval(domain.__debug, wrap_context(evaluation_context)));
+ domain_array_to_combine = py.eval(domain.__debug, wrap_context(evaluation_context));
break;
case 'compound_domain':
var eval_context = eval_contexts([domain.__eval_context]);
- result_domain.push.apply(
- result_domain, eval_domains(
- domain.__domains, _.extend(
- {}, evaluation_context, eval_context)));
+ domain_array_to_combine = eval_domains(
+ domain.__domains, _.extend({}, evaluation_context, eval_context)
+ );
break;
default:
- result_domain.push.apply(result_domain, domain);
+ domain_array_to_combine = domain;
+ }
+ if (need_normalization) {
+ domain_array_to_combine = get_normalized_domain(domain_array_to_combine);
}
+ result_domain.push.apply(result_domain, domain_array_to_combine);
});
return result_domain;
}
+/**
+ * Returns a normalized copy of the given domain array. Normalization is
+ * is making the implicit "&" at the start of the domain explicit, e.g.
+ * [A, B, C] would become ["&", "&", A, B, C].
+ *
+ * @param {Array} domain_array
+ * @returns {Array} normalized copy of the given array
+ */
+function get_normalized_domain(domain_array) {
+ var expected = 1; // Holds the number of expected domain expressions
+ _.each(domain_array, function (item) {
+ if (item === "&" || item === "|") {
+ expected++;
+ } else if (item !== "!") {
+ expected--;
+ }
+ });
+ var new_explicit_ands = _.times(-expected, _.constant("&"));
+ return new_explicit_ands.concat(domain_array);
+}
+
function eval_groupbys (contexts, evaluation_context) {
evaluation_context = _.extend(pycontext(), evaluation_context || {});
var result_group = [];