summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js
diff options
context:
space:
mode:
authorqsm-odoo <qsm@odoo.com>2017-09-14 12:37:34 +0200
committerqsm-odoo <qsm@odoo.com>2017-09-14 23:48:55 +0200
commit76ad4e71a5f2f9a334e59a336447116739625ae2 (patch)
treeef623b7e714ca37987a4a72f7a89509a50277eef /addons/web/static/src/js
parent8b00628aa2b83af2d6415804fb06564b21d157b7 (diff)
[REF] web: do kanban group manual update before saving a record move
Before this commit, when a record was moved in a kanban view, the model saved the record change then manually updated the related groups (to avoid performing a read_group and reloading the whole view). This manual update can in fact be performed before the record save. This allows customizing the save operation in some cases where a real read_group would be needed.
Diffstat (limited to 'addons/web/static/src/js')
-rw-r--r--addons/web/static/src/js/views/kanban/kanban_model.js41
1 files changed, 23 insertions, 18 deletions
diff --git a/addons/web/static/src/js/views/kanban/kanban_model.js b/addons/web/static/src/js/views/kanban/kanban_model.js
index 354657eb0d9..f714fc519df 100644
--- a/addons/web/static/src/js/views/kanban/kanban_model.js
+++ b/addons/web/static/src/js/views/kanban/kanban_model.js
@@ -144,27 +144,32 @@ var KanbanModel = BasicModel.extend({
} else {
changes[groupedFieldName] = new_group.value;
}
+
+ // Manually updates groups data. Note: this is done before the actual
+ // save as it might need to perform a read group in some cases so those
+ // updated data might be overriden again.
+ var resID = self.localData[recordID].res_id;
+ // Remove record from its current group
+ var old_group;
+ for (var i = 0; i < parent.data.length; i++) {
+ old_group = self.localData[parent.data[i]];
+ var index = _.indexOf(old_group.data, recordID);
+ if (index >= 0) {
+ old_group.data.splice(index, 1);
+ old_group.count--;
+ old_group.res_ids = _.without(old_group.res_ids, resID);
+ self._updateParentResIDs(old_group);
+ break;
+ }
+ }
+ // Add record to its new group
+ new_group.data.push(recordID);
+ new_group.res_ids.push(resID);
+ new_group.count++;
+
return this.notifyChanges(recordID, changes).then(function () {
return self.save(recordID);
}).then(function () {
- var resID = self.localData[recordID].res_id;
- // Remove record from its current group
- var old_group;
- for (var i = 0; i < parent.data.length; i++) {
- old_group = self.localData[parent.data[i]];
- var index = _.indexOf(old_group.data, recordID);
- if (index >= 0) {
- old_group.data.splice(index, 1);
- old_group.count--;
- old_group.res_ids = _.without(old_group.res_ids, resID);
- self._updateParentResIDs(old_group);
- break;
- }
- }
- // Add record to its new group
- new_group.data.push(recordID);
- new_group.res_ids.push(resID);
- new_group.count++;
return [old_group.id, new_group.id];
});
},