diff options
| author | Aaron Bohy <aab@odoo.com> | 2017-03-21 08:55:20 +0100 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2017-04-11 19:44:38 +0200 |
| commit | 740a2b1265d9f8958beb76a91fd79d1a120e85cf (patch) | |
| tree | 31559db6af82d73001832428c8a141d6d5754218 /addons/web/static/src/js/views/basic/basic_model.js | |
| parent | 9ba78dfcce85a9b115b338d6b3193bb34be43d35 (diff) | |
[FIX] web: BasicModel: keep state of groups on reload
The 'isOpen' state of groups was already kept when reloading a
(e.g.) list view. The limit and offset should be kept as well.
Diffstat (limited to 'addons/web/static/src/js/views/basic/basic_model.js')
| -rw-r--r-- | addons/web/static/src/js/views/basic/basic_model.js | 12 |
1 files changed, 7 insertions, 5 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 19500a0e442..d5f3c86cc8e 100644 --- a/addons/web/static/src/js/views/basic/basic_model.js +++ b/addons/web/static/src/js/views/basic/basic_model.js @@ -2087,13 +2087,15 @@ var BasicModel = AbstractModel.extend({ }); list.data.push(newGroup.id); list.count += newGroup.count; - var old_group = _.find(previousGroups, function (g) { + var oldGroup = _.find(previousGroups, function (g) { return g.res_id === newGroup.res_id && g.value === newGroup.value; }); - if (old_group) { - newGroup.isOpen = old_group.isOpen; - // copy the oldGroup data to keep 'isOpen' state of sub-groups - newGroup.data = newGroup.isOpen ? old_group.data : []; + if (oldGroup) { + // restore the internal state of the group + _.extend(newGroup, _.pick(oldGroup, 'limit', 'isOpen', 'offset')); + // if open, also restore the oldGroup data to keep internal + // state of sub-groups + newGroup.data = oldGroup.isOpen ? oldGroup.data : []; } else if (!newGroup.openGroupByDefault) { newGroup.isOpen = false; } else { |
