From 19dfde855841cce17b86322c92abd78359ba6a0f Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Thu, 24 Sep 2015 12:02:01 +0200 Subject: [PATCH] [FIX] web: don't trigger remove then add the record to re-order list view To re-order the list view remove the record and add the same record after. (If an onchange is called, the user can have a message to avoid remove a one2many item) Add an silent option on remove function of collection, the trigger is already call when write the sequence. --- addons/web/static/src/js/views/list_common.js | 7 +++++-- addons/web/static/src/js/views/list_view.js | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/addons/web/static/src/js/views/list_common.js b/addons/web/static/src/js/views/list_common.js index f93625e8edd..0d96b251ec2 100644 --- a/addons/web/static/src/js/views/list_common.js +++ b/addons/web/static/src/js/views/list_common.js @@ -270,9 +270,10 @@ var Collection = Class.extend(/** @lends Collection# */{ * Removes the provided record from the collection * * @param {Record} record + * @param {Boolean} [options.silent=false] * @returns this */ - remove: function (record) { + remove: function (record, options) { var index = this.indexOf(record); if (index === -1) { _(this._proxies).each(function (proxy) { @@ -285,7 +286,9 @@ var Collection = Class.extend(/** @lends Collection# */{ this.records.splice(index, 1); delete this._byId[record.get('id')]; this.length--; - this.trigger('remove', record, this); + if (!options || !options.silent) { + this.trigger('remove', record, this); + } return this; }, diff --git a/addons/web/static/src/js/views/list_view.js b/addons/web/static/src/js/views/list_view.js index 63fe3591b99..095e79eb6ee 100644 --- a/addons/web/static/src/js/views/list_view.js +++ b/addons/web/static/src/js/views/list_view.js @@ -1633,9 +1633,9 @@ ListView.Groups = Class.extend( /** @lends instance.web.ListView.Groups# */{ return; } - list.records.remove(to_move); + list.records.remove(to_move, {silent: true}); var to = target_id ? list.records.indexOf(target) + 1 : 0; - list.records.add(to_move, { at: to }); + list.records.add(to_move, { at: to, silent: true }); // resequencing time! var record, index = to,