summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorXavier Morel <xmo@openerp.com>2012-05-07 17:25:31 +0200
committerXavier Morel <xmo@openerp.com>2012-05-07 17:25:31 +0200
commit8b4fce2e7101a005a6e7bc2c978675df2eee4c5b (patch)
treea5e1f6ba780e75ff225ed27b01a832cae9119aee /addons
parentca3267d86e0fa04c1f73f8b9dca9842aeb3a5234 (diff)
[FIX] incorrect propagation of deferreds (&state) in Kanban view when grouped
bzr revid: xmo@openerp.com-20120507152531-8x2ozsvhbb5yemqt
Diffstat (limited to 'addons')
-rw-r--r--addons/web_kanban/static/src/js/kanban.js35
1 files changed, 16 insertions, 19 deletions
diff --git a/addons/web_kanban/static/src/js/kanban.js b/addons/web_kanban/static/src/js/kanban.js
index d3ba0c74f5a..928a06d8ba2 100644
--- a/addons/web_kanban/static/src/js/kanban.js
+++ b/addons/web_kanban/static/src/js/kanban.js
@@ -148,25 +148,22 @@ instance.web_kanban.KanbanView = instance.web.View.extend({
do_process_groups: function(groups) {
var self = this;
this.add_group_mutex.exec(function() {
- var def = $.Deferred();
self.do_clear_groups();
self.dataset.ids = [];
var remaining = groups.length - 1,
groups_array = [];
- _.each(groups, function (group, index) {
+ return $.when.apply(null, _.map(groups, function (group, index) {
var dataset = new instance.web.DataSetSearch(self, self.dataset.model, group.context, group.domain);
- dataset.read_slice(self.fields_keys.concat(['__last_update']), { 'limit': self.limit }).then(function(records) {
- self.dataset.ids.push.apply(self.dataset.ids, dataset.ids);
- groups_array[index] = new instance.web_kanban.KanbanGroup(self, records, group, dataset);
- if (!remaining--) {
- self.dataset.index = self.dataset.size() ? 0 : null;
- def.pipe(self.do_add_groups(groups_array));
- }
- }).then(null, function() {
- def.reject();
+ return dataset.read_slice(self.fields_keys.concat(['__last_update']), { 'limit': self.limit })
+ .pipe(function(records) {
+ self.dataset.ids.push.apply(self.dataset.ids, dataset.ids);
+ groups_array[index] = new instance.web_kanban.KanbanGroup(self, records, group, dataset);
+ if (!remaining--) {
+ self.dataset.index = self.dataset.size() ? 0 : null;
+ return self.do_add_groups(groups_array);
+ }
});
- });
- return def;
+ }));
});
},
do_process_dataset: function(dataset) {
@@ -196,16 +193,16 @@ instance.web_kanban.KanbanView = instance.web.View.extend({
this.$element.find('.oe_kanban_groups_headers, .oe_kanban_groups_records').empty();
},
do_add_groups: function(groups) {
- var self = this,
- def = $.Deferred().resolve();
+ var self = this;
_.each(groups, function(group) {
self.groups[group.undefined_title ? 'unshift' : 'push'](group);
});
- _.each(this.groups, function(group) {
- def.pipe(group.appendTo(self.$element.find('.oe_kanban_groups_headers')));
+ var groups_started = _.map(this.groups, function(group) {
+ return group.appendTo(self.$element.find('.oe_kanban_groups_headers'));
+ });
+ return $.when.apply(null, groups_started).then(function () {
+ self.on_groups_started();
});
- this.on_groups_started();
- return def;
},
on_groups_started: function() {
var self = this;