summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js
diff options
context:
space:
mode:
authorNicolas Martinelli <nim@odoo.com>2018-04-10 14:54:33 +0200
committerNicolas Martinelli <nim-odoo@users.noreply.github.com>2018-04-11 11:24:02 +0200
commit33ba61bfdbdc1d9d986070c677f6bf18cbacf6b2 (patch)
treee99052595d99bd2e07fe74ac44c1dd54086042d1 /addons/web/static/src/js
parent5bb65170724dcd86cebd41a5b37509c6ed145ae6 (diff)
[FIX] web: domain evaluation
To reproduce the error, go to Accounting > Import Statement, then Cancel. An error occurs because `belongs_to_company` is not in the data. Indeed, it is directly set on the action `open_account_journal_dashboard_kanban`. Commit 9961bbf4eb87f re-evaluates if a record should be displayed in the Kanban view after applying an action (in particular, archive a record). However, the domain evaluated might contain values which are not in the data. This is for example the case if there is a domain on an action. Fixes #24142 opw-1835216 opw-1835123
Diffstat (limited to 'addons/web/static/src/js')
-rw-r--r--addons/web/static/src/js/views/kanban/kanban_controller.js43
1 files changed, 38 insertions, 5 deletions
diff --git a/addons/web/static/src/js/views/kanban/kanban_controller.js b/addons/web/static/src/js/views/kanban/kanban_controller.js
index 20a8e11cd52..11d17a78fa9 100644
--- a/addons/web/static/src/js/views/kanban/kanban_controller.js
+++ b/addons/web/static/src/js/views/kanban/kanban_controller.js
@@ -238,12 +238,45 @@ var KanbanController = BasicController.extend({
var kanban_record = event.target;
kanban_record.update(data);
- // Check if we still need to display the record
- var domain = parent ? parent.domain : group.domain;
- if ('active' in data.data && _.pluck(domain, 0).indexOf('active') === -1) {
- domain = [['active', '=', true]].concat(domain);
+ // Check if we still need to display the record. Some fields of the domain are
+ // not guaranteed to be in data. This is for example the case if the action
+ // contains a domain on a field which is not in the Kanban view. Therefore,
+ // we need to handle multiple cases based on 3 variables:
+ // domInData: all domain fields are in the data
+ // activeInDomain: 'active' is already in the domain
+ // activeInData: 'active' is available in the data
+
+ var domain = (parent ? parent.domain : group.domain) || [];
+ var domInData = _.every(domain, function (d) {
+ return d[0] in data.data;
+ });
+ var activeInDomain = _.pluck(domain, 0).indexOf('active') !== -1;
+ var activeInData = 'active' in data.data;
+
+ // Case # | domInData | activeInDomain | activeInData
+ // 1 | true | true | true => no domain change
+ // 2 | true | true | false => not possible
+ // 3 | true | false | true => add active in domain
+ // 4 | true | false | false => no domain change
+ // 5 | false | true | true => no evaluation
+ // 6 | false | true | false => no evaluation
+ // 7 | false | false | true => replace domain
+ // 8 | false | false | false => no evaluation
+
+ // There are 3 cases which cannot be evaluated since we don't have all the
+ // necessary information. The complete solution would be to perform a RPC in
+ // these cases, but this is out of scope. A simpler one is to do a try / catch.
+
+ if (domInData && !activeInDomain && activeInData) {
+ domain = domain.concat([['active', '=', true]]);
+ } else if (!domInData && !activeInDomain && activeInData) {
+ domain = [['active', '=', true]];
+ }
+ try {
+ var visible = new Domain(domain).compute(data.evalContext);
+ } catch (e) {
+ return;
}
- var visible = new Domain(domain).compute(data.evalContext);
if (!visible) {
kanban_record.destroy();
}