diff options
| author | Géry Debongnie <ged@odoo.com> | 2017-03-25 09:40:58 +0100 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2017-04-11 19:44:38 +0200 |
| commit | 1c7fa2e72dd2b6d97d38a32d4246163ae8ef9200 (patch) | |
| tree | a6f8b56ed502e6008f95620c716f3e2bfdd9bfbd /addons/web/static/src/js | |
| parent | 556ee204d0edc888f31193a8068503deef3d1ee2 (diff) | |
[FIX] web: pivot view should not crash when sorting
Diffstat (limited to 'addons/web/static/src/js')
| -rw-r--r-- | addons/web/static/src/js/views/pivot/pivot_controller.js | 2 | ||||
| -rw-r--r-- | addons/web/static/src/js/views/pivot/pivot_model.js | 13 |
2 files changed, 7 insertions, 8 deletions
diff --git a/addons/web/static/src/js/views/pivot/pivot_controller.js b/addons/web/static/src/js/views/pivot/pivot_controller.js index 9b154214dfc..2aa4cd93797 100644 --- a/addons/web/static/src/js/views/pivot/pivot_controller.js +++ b/addons/web/static/src/js/views/pivot/pivot_controller.js @@ -344,7 +344,7 @@ var PivotController = AbstractController.extend({ var isAscending = $target.hasClass('o_pivot_measure_row_sorted_asc'); this.model .sortRows(this.handle, col_id, measure, isAscending) - .then(this.update_state.bind(this)); + .then(this.update.bind(this, {}, {reload: false})); }, /** * This method is called when someone clicks on an open header. When that diff --git a/addons/web/static/src/js/views/pivot/pivot_model.js b/addons/web/static/src/js/views/pivot/pivot_model.js index ff0b80dd103..d2bf632053c 100644 --- a/addons/web/static/src/js/views/pivot/pivot_model.js +++ b/addons/web/static/src/js/views/pivot/pivot_model.js @@ -284,21 +284,20 @@ var PivotModel = AbstractModel.extend({ * @returns {Deferred} */ sortRows: function (id, col_id, measure, descending) { - var record = this.localData[id]; - - _traverseTree(record.data.main_row.root, function (header) { + var cells = this.data.cells; + this._traverseTree(this.data.main_row.root, function (header) { header.children.sort(compare); }); - record.sorted_column = { + this.data.sorted_column = { id: col_id, measure: measure, order: descending ? 'desc' : 'asc', }; function _getValue (id1, id2) { - if ((id1 in record.data.cells) && (id2 in record.data.cells[id1])) { - return record.data.cells[id1][id2]; + if ((id1 in cells) && (id2 in cells[id1])) { + return cells[id1][id2]; } - if (id2 in record.data.cells) return record.data.cells[id2][id1]; + if (id2 in cells) return cells[id2][id1]; } function compare (row1, row2) { |
