[FIX] web_kanban: wrong condition to reset the dataset index
authorDenis Ledoux <dle@odoo.com>
Tue, 4 Nov 2014 16:45:53 +0000 (17:45 +0100)
committerDenis Ledoux <dle@odoo.com>
Tue, 4 Nov 2014 16:47:53 +0000 (17:47 +0100)
This is related to rev. a218a9ed3f6c965820f2ebdf76ee0e6c89c59a0c

The condition is good, but not in the right place: It should be done once all read_slice (all columns records) are fetched, not at each read_slice end

addons/web_kanban/static/src/js/kanban.js

index a0d1635..23fa492 100644 (file)
@@ -260,8 +260,8 @@ instance.web_kanban.KanbanView = instance.web.View.extend({
                 self.no_result();
                 return false;
             }
-            var remaining = groups.length - 1,
-                groups_array = [];
+            self.nb_records = 0;
+            var groups_array = [];
             return $.when.apply(null, _.map(groups, function (group, index) {
                 var def = $.when([]);
                 var dataset = new instance.web.DataSetSearch(self, self.dataset.model,
@@ -270,16 +270,16 @@ instance.web_kanban.KanbanView = instance.web.View.extend({
                     def = dataset.read_slice(self.fields_keys.concat(['__last_update']), { 'limit': self.limit });
                 }
                 return def.then(function(records) {
+                        self.nb_records += records.length;
                         self.dataset.ids.push.apply(self.dataset.ids, dataset.ids);
                         groups_array[index] = new instance.web_kanban.KanbanGroup(self, records, group, dataset);
-                        if (self.dataset.index >= records.length){
-                            self.dataset.index = self.dataset.size() ? 0 : null;
-                        }
-                        if (!remaining--) {
-                            return self.do_add_groups(groups_array);
-                        }
                 });
-            }));
+            })).then(function () {
+                if (self.dataset.index >= self.nb_records){
+                    self.dataset.index = self.dataset.size() ? 0 : null;
+                }
+                return self.do_add_groups(groups_array);
+            });
         });
     },
     do_process_dataset: function() {