From 7d1957da8f563d096514b587ec96aede5b204007 Mon Sep 17 00:00:00 2001 From: Vincent Schippefilt Date: Tue, 5 Feb 2019 12:54:29 +0000 Subject: [FIX] web: hang when saving then discarding When editing a record, if it cannot be saved (b.e. due to required fields) and the user clicks on save, then on discard Before this fix, the window did nothing (seems like it is unresponsive) After this fix, the user is able to discard the form. task-id: 1937142 closes odoo/odoo#30871 --- addons/web/static/src/js/views/basic/basic_controller.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'addons/web/static/src/js/views/basic/basic_controller.js') diff --git a/addons/web/static/src/js/views/basic/basic_controller.js b/addons/web/static/src/js/views/basic/basic_controller.js index 01bbd9cd2fe..16204c83163 100644 --- a/addons/web/static/src/js/views/basic/basic_controller.js +++ b/addons/web/static/src/js/views/basic/basic_controller.js @@ -188,12 +188,18 @@ var BasicController = AbstractController.extend(FieldManagerMixin, { // mutex-protected as commitChanges function of x2m has to be aware of // all final changes made to a row. var self = this; - this.savingDef = this.mutex.getUnlockedDef().then(function () { - return self.renderer.commitChanges(recordID || self.handle).then(function () { + var savingDef = $.Deferred(); + this.savingDef = savingDef; + + return this.mutex.getUnlockedDef() + .then(function () { + return self.renderer.commitChanges(recordID || self.handle); + }) + .then(function () { return self.mutex.exec(self._saveRecord.bind(self, recordID, options)); - }); - }); - return this.savingDef; + }) + .then(savingDef.resolve.bind(savingDef)) + .fail(savingDef.resolve.bind(savingDef)); }, /** * @override -- cgit v1.2.3