[FIX] web_kanban: traceback when quickly drag&dropping

... records on models having a sequence field (e.g. project.task).

When a record is dragged and dropped, the following RPCs are done:
 - write (the new group id on the moved record)
 - read (the moved record)
 - resequence (the column where the record has been moved to)

To perform the resequence RPC, we need to retrieve the list of ids
of the records being in the column. We do that by iterating over
the cards in the column and reading the id in their data attribute.

However, a traceback might occur if the resequence was triggered
exactly when the user was holding a record over the column being
resequenced, because jquery-ui creates a placeholder for the record
being dragged and dropped, and this placeholder doesn't have the
required data attribute.
This commit is contained in:
Aaron Bohy
2017-05-10 11:10:38 +02:00
parent 4e205b7549
commit e4e2735e87
@@ -161,7 +161,14 @@ var KanbanColumn = Widget.extend({
get_ids: function () {
var ids = [];
this.$('.o_kanban_record').each(function (index, r) {
ids.push($(r).data('record').id);
var record = $(r).data('record');
// when a record is being dragged & dropped, an empty .o_kanban_record
// element (a placeholder) is present in the column, but it has no
// associated record (the real o_kanban_record is still in the
// column, but hidden), so we need to filter out those placeholders
if (record) {
ids.push(record.id);
}
});
return ids;
},