From 970c92abfc4ea657842f7e4bf7e1ae76c4f258c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 25 Oct 2016 23:14:20 +0200 Subject: [PATCH] Use cancel_record instead of removing from group cancel_record uses Screen.remove which ensure the cursor is correctly set after the removal. This also ensure that cancel_record remove only the current record. issue5852 review29641002 --- src/screen.js | 13 ++++--------- src/window.js | 2 +- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/screen.js b/src/screen.js index b216d6e164..c127f34e3d 100644 --- a/src/screen.js +++ b/src/screen.js @@ -1082,7 +1082,8 @@ if (this.current_record) { this.current_record.cancel(); if (this.current_record.id < 0) { - prms.push(this.remove()); + prms.push(this.remove( + false, false, false, [this.current_record])); } } return jQuery.when.apply(jQuery, prms); @@ -1163,14 +1164,8 @@ record.group.unremove(record); }); }, - remove: function(delete_, remove, force_remove) { - var records = null; - if ((this.current_view.view_type == 'form') && - this.current_record) { - records = [this.current_record]; - } else if (this.current_view.view_type == 'tree') { - records = this.current_view.selected_records(); - } + remove: function(delete_, remove, force_remove, records) { + records = records | this.current_view.selected_records(); if (jQuery.isEmptyObject(records)) { return; } diff --git a/src/window.js b/src/window.js index 584fac9bb1..893cefc63f 100644 --- a/src/window.js +++ b/src/window.js @@ -358,7 +358,7 @@ this.screen.current_record) { result = false; if ((this.screen.current_record.id < 0) || this.save_current) { - this.screen.group.remove(this.screen.current_record, true); + this.screen.cancel_current(); } else if (this.screen.current_record.has_changed()) { this.screen.current_record.cancel(); this.screen.current_record.reload().always(function() {