[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).
This commit is contained in:
qsm-odoo
2017-09-14 23:48:54 +02:00
parent f1370dfa0a
commit 5c6a7c9ea9
@@ -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));
}