diff options
| author | qsm-odoo <qsm@odoo.com> | 2017-09-14 15:02:30 +0200 |
|---|---|---|
| committer | qsm-odoo <qsm@odoo.com> | 2017-09-14 23:48:54 +0200 |
| commit | 5c6a7c9ea9534d805a7c2e183fe1bd6dc730cf41 (patch) | |
| tree | 43396b734679658b7932b49462c39292374b8ede /addons/web/static/src/js/views | |
| parent | f1370dfa0abac2b50315e47dccd0daf906336fc5 (diff) | |
[REF] web: do not update groups model ID on read_group update
Performing a 'read_group' was creating new model group data which were
saving some properties of the old model group data. As KanbanColumn
widgets may not be updated in each case where we might want to re-do
a (partial) 'read_group', this commit changes the system so that old
model group data are simply updated with the useful new group data
properties (instead of being entirely replaced).
Diffstat (limited to 'addons/web/static/src/js/views')
| -rw-r--r-- | addons/web/static/src/js/views/basic/basic_model.js | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/addons/web/static/src/js/views/basic/basic_model.js b/addons/web/static/src/js/views/basic/basic_model.js index d3a60ac3044..90557eabba0 100644 --- a/addons/web/static/src/js/views/basic/basic_model.js +++ b/addons/web/static/src/js/views/basic/basic_model.js @@ -3406,24 +3406,28 @@ var BasicModel = AbstractModel.extend({ type: 'list', viewType: list.viewType, }); - list.data.push(newGroup.id); - list.count += newGroup.count; var oldGroup = _.find(previousGroups, function (g) { return g.res_id === newGroup.res_id && g.value === newGroup.value; }); if (oldGroup) { // restore the internal state of the group - _.extend(newGroup, _.pick(oldGroup, 'limit', 'isOpen', 'offset')); - // if the group is open and contains subgroups, also - // restore its data to keep internal state of sub-groups - if (newGroup.isOpen && newGroup.groupedBy.length) { - newGroup.data = oldGroup.data; + delete self.localData[newGroup.id]; + var updatedProps = _.omit(newGroup, 'limit', 'isOpen', 'offset', 'id'); + if (oldGroup.isOpen && newGroup.groupedBy.length) { + // If the group is opened and contains subgroups, + // also keep its data to keep internal state of + // sub-groups + delete updatedProps.data; } + _.extend(oldGroup, updatedProps); + newGroup = oldGroup; } else if (!newGroup.openGroupByDefault) { newGroup.isOpen = false; } else { newGroup.isOpen = '__fold' in group ? !group.__fold : true; } + list.data.push(newGroup.id); + list.count += newGroup.count; if (newGroup.isOpen && newGroup.count > 0) { defs.push(self._load(newGroup)); } |
