From 6782c33a32fd8ccdfc6b00387beba532e64bf5cf Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Thu, 18 Oct 2012 15:41:23 +0200 Subject: [PATCH] [FIX] only reload m2m listview once after adding n records to it (via dialog) The listview does not support concurrent reload requests, either wait for the previous reload to finish before sending the new one, or just send a single reload. For m2m, can wait and do a single reload so do that. bzr revid: xmo@openerp.com-20121018134123-ox2ccq0wm3r5jwas --- addons/web/static/src/js/view_form.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 6f525f7a8b5..b2caf70dbbe 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -4048,13 +4048,17 @@ instance.web.form.Many2ManyListView = instance.web.ListView.extend(/** @lends in ); var self = this; pop.on("elements_selected", self, function(element_ids) { - _.each(element_ids, function(one_id) { - if(! _.detect(self.dataset.ids, function(x) {return x == one_id;})) { - self.dataset.set_ids([].concat(self.dataset.ids, [one_id])); + var reload = false; + _(element_ids).each(function (id) { + if(! _.detect(self.dataset.ids, function(x) {return x == id;})) { + self.dataset.set_ids(self.dataset.ids.concat([id])); self.m2m_field.dataset_changed(); - self.reload_content(); + reload = true; } }); + if (reload) { + self.reload_content(); + } }); }, do_activate_record: function(index, id) {