From 9f9bbcff33a5a3153a22ea6f736b8c668c4f5a81 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Wed, 13 Jun 2012 17:36:33 +0200 Subject: [PATCH] [FIX] in ensure_saved, discard non-dirty editable rows if the editable row's form isn't dirty, either nothing has been entered in a new row or an existing row (being edited) has not been altered, so can just discard the row (and reload it from cache if it's an edition). bzr revid: xmo@openerp.com-20120613153633-ms7i8t9lvdarxqi3 --- addons/web/static/src/js/view_list_editable.js | 8 +++++++- 1 file changed, 7 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 728652edc5f..7a0645138bf 100644 --- a/addons/web/static/src/js/view_list_editable.js +++ b/addons/web/static/src/js/view_list_editable.js @@ -332,7 +332,13 @@ openerp.web.list_editable = function (openerp) { */ ensure_saved: function () { if (this.edition) { - return this.save_row(); + // kinda-hack-ish: if the user has entered data in a field, + // oe_form_dirty will be set on the form so save, otherwise + // discard the current (entirely empty) line + if (this.edition_form.$element.is('.oe_form_dirty')) { + return this.save_row(); + } + return this.cancel_pending_edition(); } //noinspection JSPotentiallyInvalidConstructorUsage return $.when();