summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/views/basic/basic_model.js
diff options
context:
space:
mode:
authorAaron Bohy <aab@odoo.com>2017-08-14 12:38:14 +0200
committerAaron Bohy <aab@odoo.com>2017-08-16 13:03:33 +0200
commitb5b8e66b900e78dc3228946e15d517f91a214703 (patch)
treef9c52b71317f882c6c0cbedb72874fa1f6a7b80a /addons/web/static/src/js/views/basic/basic_model.js
parent591927cfe0cf968119e271b8f61d86ba10397205 (diff)
[FIX] web: grouped views: update pager
The problem occured when opening a record from a grouped list or kanban view. In the opened form view, the pager was sometimes incorrect. This was because the list of ids wasn't correctly updated when groups were opened/folded.
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.js27
1 files changed, 26 insertions, 1 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 72a89a23cc2..e8409487abc 100644
--- a/addons/web/static/src/js/views/basic/basic_model.js
+++ b/addons/web/static/src/js/views/basic/basic_model.js
@@ -919,18 +919,23 @@ var BasicModel = AbstractModel.extend({
* @returns {Deferred -> string} resolves to the group id
*/
toggleGroup: function (groupId) {
+ var self = this;
var group = this.localData[groupId];
if (group.isOpen) {
group.isOpen = false;
group.data = [];
+ group.res_ids = [];
group.offset = 0;
+ this._updateParentResIDs(group);
return $.when(groupId);
}
if (!group.isOpen) {
group.isOpen = true;
var def;
if (group.count > 0) {
- def = this._load(group);
+ def = this._load(group).then(function () {
+ self._updateParentResIDs(group);
+ });
}
return $.when(def).then(function () {
return groupId;
@@ -3401,6 +3406,26 @@ var BasicModel = AbstractModel.extend({
}
},
/**
+ * Updates the res_ids of the parent of a given element of type list.
+ *
+ * After some operations (e.g. loading more records, folding/unfolding a
+ * group), the res_ids list of an element may be updated. When this happens,
+ * the res_ids of its ancestors need to be updated as well. This is the
+ * purpose of this function.
+ *
+ * @param {Object} element
+ */
+ _updateParentResIDs: function (element) {
+ var self = this;
+ if (element.parentID) {
+ var parent = this.localData[element.parentID];
+ parent.res_ids = _.flatten(_.map(parent.data, function (dataPointID) {
+ return self.localData[dataPointID].res_ids;
+ }));
+ this._updateParentResIDs(parent);
+ }
+ },
+ /**
* Helper method. Recursively traverses the data, starting from the element
* record (or list), then following all relations. This is useful when one
* want to determine a property for the current record.