summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/views/kanban/kanban_controller.js
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2018-04-16 18:34:56 +0200
committerChristophe Simonis <chs@odoo.com>2018-04-16 18:34:56 +0200
commit5f2d080cf85d54bc52895f9dbc4075b10989d324 (patch)
treec925509b609fb07f6fbef8896710b756c3c6a86f /addons/web/static/src/js/views/kanban/kanban_controller.js
parent026be48ccbbb15daefda070697b135f089f49564 (diff)
parentad825b673b57344a6a1571234f62a0b3aa543bf7 (diff)
[MERGE] forward port branch 11.0 up to ad825b673b5
Diffstat (limited to 'addons/web/static/src/js/views/kanban/kanban_controller.js')
-rw-r--r--addons/web/static/src/js/views/kanban/kanban_controller.js48
1 files changed, 48 insertions, 0 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 8a779becdea..9c227fba2ac 100644
--- a/addons/web/static/src/js/views/kanban/kanban_controller.js
+++ b/addons/web/static/src/js/views/kanban/kanban_controller.js
@@ -10,6 +10,7 @@ odoo.define('web.KanbanController', function (require) {
var BasicController = require('web.BasicController');
var Context = require('web.Context');
var core = require('web.core');
+var Domain = require('web.Domain');
var view_dialogs = require('web.view_dialogs');
var _t = core._t;
@@ -189,10 +190,57 @@ var KanbanController = BasicController.extend({
resIDs: record.res_ids,
},
on_closed: function () {
+ var recordModel = self.model.localData[record.id];
+ var group = self.model.localData[recordModel.parentID];
+ var parent = self.model.localData[group.parentID];
+
self.model.reload(record.id).then(function (db_id) {
var data = self.model.get(db_id);
var kanban_record = event.target;
kanban_record.update(data);
+
+ // 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;
+ }
+ if (!visible) {
+ kanban_record.destroy();
+ }
});
},
});