From 19d5cb01c7664c6e642cdbef94f1095a8fa92167 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Tue, 19 Jun 2012 13:03:50 +0200 Subject: [PATCH] [FIX] error caused by autosave-on-blur when vaidating a row with [Return] bzr revid: xmo@openerp.com-20120619110350-64sb4uy2t1eydiou --- addons/web/static/src/js/view_form.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index fde415347f0..920316c6f35 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -2730,16 +2730,30 @@ openerp.web.form.One2ManyListView = openerp.web.ListView.extend({ } }); openerp.web.form.One2ManyList = openerp.web.ListView.List.extend({ + KEY_RETURN: 13, + // blurring caused by hitting the [Return] key, should skip the + // autosave-on-blur and let the handler for [Return] do its thing + __return_blur: false, render_row_as_form: function () { var self = this; return this._super.apply(this, arguments).then(function () { $(self.edition_form).bind('form-blur', function () { + if (self.__return_blur) { + delete self.__return_blur; + return; + } if (!self.edition_form.widget_is_stopped) { self.view.ensure_saved(); } }); }); }, + on_row_keyup: function (e) { + if (e.which === this.KEY_RETURN) { + this.__return_blur = true; + } + this._super(e); + } }); openerp.web.form.One2ManyFormView = openerp.web.FormView.extend({