From 28cbfd22b782198db100fd4eb40d95cf9c3a1fd0 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Mon, 19 Nov 2012 09:42:03 +0100 Subject: [PATCH] [FIX] editable listview: do not attempt to delete falsy ids (from the dataset) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit During the creation of a new record (in an editable list), the prospective new record has a ``false`` id. In a non-o2m, the row under creation can be selected (checkbox) and deleted (More > Delete), leading to the request to ``DELETE false`` being sent to the ORM… which said ORM does not wish to entertain. Before actually performing the delete request (more precisely forwarding said request to the listview itself), remove all false-ish ids from the array. Also, don't send a request to delete nothing. bzr revid: xmo@openerp.com-20121119084203-0vz4v9myfizxz88u --- addons/web/static/src/js/view_list_editable.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/web/static/src/js/view_list_editable.js b/addons/web/static/src/js/view_list_editable.js index 1abe3caab39..c42f79d57f9 100644 --- a/addons/web/static/src/js/view_list_editable.js +++ b/addons/web/static/src/js/view_list_editable.js @@ -78,12 +78,16 @@ openerp.web.list_editable = function (instance) { _.extend(this.dataset, dataset); }, do_delete: function (ids) { + var nonfalse = _.compact(ids); var _super = this._super.bind(this); var next = this.editor.is_editing() ? this.cancel_edition(true) : $.when(); return next.then(function () { - return _super(ids); + if (_.isEmpty(nonfalse)) { + return $.when(); + } + return _super(nonfalse); }); }, editable: function () {