From 5c6a7c9ea9534d805a7c2e183fe1bd6dc730cf41 Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Thu, 14 Sep 2017 15:02:30 +0200 Subject: [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). --- addons/web/static/src/js/views/basic/basic_model.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'addons/web/static/src/js/views/basic/basic_model.js') 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)); } -- cgit v1.2.3