From 9b54b042a03564b8f808b0fff292573a73ef3044 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Fri, 15 Apr 2016 10:12:08 +0200 Subject: [PATCH] [FIX] web_kanban: correct count for dataset size In non grouped mode, a recent fix (fixing race condition in do_search) introduced a new bug, the dataset size is not correctly set. This is a quick and dirty fix, I believe that changing the dataset internals like this commit (and other) do is really not correct. However, the correct fix (working on the dataset API) is more dangerous in a stable release. --- addons/web_kanban/static/src/js/kanban_view.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/addons/web_kanban/static/src/js/kanban_view.js b/addons/web_kanban/static/src/js/kanban_view.js index 42fe0908e77..e8c6d806fe4 100644 --- a/addons/web_kanban/static/src/js/kanban_view.js +++ b/addons/web_kanban/static/src/js/kanban_view.js @@ -138,6 +138,7 @@ var KanbanView = View.extend({ })); } else { new_ids = _.pluck(data.records, 'id'); + self.dataset._length = data.count; } self.dataset.alter_ids(new_ids); self.data = data; @@ -157,17 +158,20 @@ var KanbanView = View.extend({ load_records: function (offset, dataset) { dataset = dataset || this.dataset; - return dataset._model.query(this.fields_keys.concat(['__last_update'])) + var query = dataset._model.query(this.fields_keys.concat(['__last_update'])) .limit(this.limit || false) - .offset(offset || 0) - .all() - .then(function (records) { + .offset(offset || 0); + return query.all() + .then(function (records) { + return query.count().then(function(count) { return { records: records, is_empty: !records.length, grouped: false, + count: count, }; - }); + }) + }); }, load_groups: function (options) {