From c58ebcfaeddf5b6dfbbd8baed785fa8045919009 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Tue, 6 Dec 2011 13:37:35 +0100 Subject: [PATCH] [FIX] records disappearing from sequenceable list views when dropped onto their original position In the listview's backing Records, a noop set (setting a property to the value it already has) has no visible effect (no even is triggered, it is simply ignored). The listview relies on setting the sequence number to refresh records and re-display them correctly in their table rows, but dropping an already sequenced row onto itself would set its sequence to its current value (barring record removals), yielding to no refresh and the row simply poofing out of view as it gets removed from the collection (and the table), then added back to the collection in its new (and old) position and displayed in a bare-bones empty states waiting for a render_record call. Added a check to sorting management to bail out immediately if a sort is a noop (the row is dropped at the same position it was taken from) lp bug: https://launchpad.net/bugs/900207 fixed bzr revid: xmo@openerp.com-20111206123735-4bfnqh1zl7u4ozm9 --- addons/web/static/src/js/view_list.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/addons/web/static/src/js/view_list.js b/addons/web/static/src/js/view_list.js index 73cf453d4ca..de7dd1a77f5 100644 --- a/addons/web/static/src/js/view_list.js +++ b/addons/web/static/src/js/view_list.js @@ -1281,10 +1281,15 @@ openerp.web.ListView.Groups = openerp.web.Class.extend( /** @lends openerp.web.L items: '> tr[data-id]', stop: function (event, ui) { var to_move = list.records.get(ui.item.data('id')), - target_id = ui.item.prev().data('id'); + target_id = ui.item.prev().data('id'), + from_index = list.records.indexOf(to_move), + target = list.records.get(target_id); + if (list.records.at(from_index - 1) == target) { + return; + } list.records.remove(to_move); - var to = target_id ? list.records.indexOf(list.records.get(target_id)) + 1 : 0; + var to = target_id ? list.records.indexOf(target) + 1 : 0; list.records.add(to_move, { at: to }); // resequencing time!