Skip to content
Permalink
Browse files

[REF] web: correctly reuse read_group old datapoint

Rev. 5c6a7c9 made a change to reuse an old group datapoint when
performing a read_group, instead of restoring *some* properties of the old
group (so basically a `_.omit` instead of a `_.pick`).

This is a bad idea as some properties were bound to the new datapoint
(`evaluateModifiers` for example) so it doesn't make any sense to update
the old datapoint with theses properties.
  • Loading branch information...
mge-odoo committed Mar 19, 2019
1 parent edd659f commit 69d03a9d3b2bebe5b2f77127fb11a2b4c7bb0409
Showing with 6 additions and 6 deletions.
  1. +6 −6 addons/web/static/src/js/views/basic/basic_model.js
@@ -4250,22 +4250,22 @@ var BasicModel = AbstractModel.extend({
return g.res_id === newGroup.res_id && g.value === newGroup.value;
});
if (oldGroup) {
// restore the internal state of the group
delete self.localData[newGroup.id];
var updatedProps = _.omit(newGroup, 'limit', 'isOpen', 'offset', 'id');
// restore the internal state of the group
var updatedProps = _.pick(oldGroup, 'limit', 'isOpen', 'offset', 'id');
if (options && options.onlyGroups || oldGroup.isOpen && newGroup.groupedBy.length) {
// If the group is opened and contains subgroups,
// also keep its data to keep internal state of
// sub-groups
// Also keep data if we only reload groups' own data
delete updatedProps.data;
updatedProps.data = oldGroup.data;
}
_.extend(newGroup, updatedProps);
// set the limit such that all previously loaded records
// (e.g. if we are coming back to the kanban view from a
// form view) are reloaded
oldGroup.limit = oldGroup.limit + oldGroup.loadMoreOffset;
_.extend(oldGroup, updatedProps);
newGroup = oldGroup;
newGroup.limit = oldGroup.limit + oldGroup.loadMoreOffset;
self.localData[newGroup.id] = newGroup;
} else if (!newGroup.openGroupByDefault || openGroupCount >= self.OPEN_GROUP_LIMIT) {
newGroup.isOpen = false;
} else {

0 comments on commit 69d03a9

Please sign in to comment.
You can’t perform that action at this time.