From 22b1f5ce0c19b11c96dbd36b3b2c2104ef4d79d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Tue, 9 Sep 2014 12:26:16 +0200 Subject: [FIX] web: fixes issues with custom filters and search view The problem was that when the user manipulates the graph view (in pivot table mode), the graph view resetted the group by facet in the search view. It was not a problem unless a custom filter with a groupby was already there, in which case, the group bys were duplicated. The search view is now smarter, it only resets the additional groupbys (and col_groupbys). Also, to prevent usability problems, the graph view disable the '+/-' groupbys added by a custom filters. Note that this fix is only temporary: a revamp of custom filters, facets, search view is coming in the next months. (at least, that's the idea). Right now, too much 'search logic' is in the graph view. Another note: this fix is somewhat fragile: it makes some assumptions about the search query (mainly that the custom filter is the first facet, also, that no other filters add groupbys/col_groupbys) --- addons/web/static/src/js/pyeval.js | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'addons/web/static/src/js/pyeval.js') diff --git a/addons/web/static/src/js/pyeval.js b/addons/web/static/src/js/pyeval.js index d5499a028b7..bad98e7b2a0 100644 --- a/addons/web/static/src/js/pyeval.js +++ b/addons/web/static/src/js/pyeval.js @@ -888,15 +888,9 @@ return new $.Deferred(function (d) {setTimeout(function () { var result; try { - var contexts = ([instance.session.user_context] || []).concat(source.contexts); - // see Session.eval_context in Python - result = { - context: instance.web.pyeval.eval('contexts', contexts), - domain: instance.web.pyeval.eval('domains', source.domains), - group_by: instance.web.pyeval.eval('groupbys', source.group_by_seq || []) - }; - - } catch (e) { + result = instance.web.pyeval.sync_eval_domains_and_contexts(source); + } + catch (e) { result = { error: { code: 400, message: instance.web._t("Evaluation Error"), @@ -906,9 +900,18 @@ instance.web._t("Local evaluation failure\n%s\n\n%s"), e.message, JSON.stringify(source)) } - }}; + }}; } d.resolve(result); }, 0); }); }; + instance.web.pyeval.sync_eval_domains_and_contexts = function (source) { + var contexts = ([instance.session.user_context] || []).concat(source.contexts); + // see Session.eval_context in Python + return { + context: instance.web.pyeval.eval('contexts', contexts), + domain: instance.web.pyeval.eval('domains', source.domains), + group_by: instance.web.pyeval.eval('groupbys', source.group_by_seq || []) + }; + }; })(); -- cgit v1.2.3