From 4f64fa3e78b480b8e0dc7fc903d2f8f2e7107d82 Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Fri, 5 Jun 2020 15:16:32 +0000 Subject: [PATCH] [FIX] website: prevent saving multiple times in a row While waiting for a better and more robust fix in the editor itself, this prevents to hit the save button of the website editor while a save is in progress. closes odoo/odoo#52540 Signed-off-by: Quentin Smetz (qsm) --- addons/website/static/src/js/editor/editor_menu.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/addons/website/static/src/js/editor/editor_menu.js b/addons/website/static/src/js/editor/editor_menu.js index dbeba41a7c5..c78e48f13ad 100644 --- a/addons/website/static/src/js/editor/editor_menu.js +++ b/addons/website/static/src/js/editor/editor_menu.js @@ -108,10 +108,14 @@ var EditorMenu = Widget.extend({ * * @param {boolean} [reload=true] * true if the page has to be reloaded after the save - * @returns {Deferred} + * @returns {Promise} */ - save: function (reload) { + save: async function (reload) { + if (this._saving) { + return false; + } var self = this; + this._saving = true; this.trigger_up('edition_will_stopped'); return this.wysiwyg.save(false).then(function (result) { var $wrapwrap = $('#wrapwrap'); @@ -125,6 +129,9 @@ var EditorMenu = Widget.extend({ self.trigger_up('edition_was_stopped'); self.destroy(); } + return true; + }).guardedCatch(() => { + this._saving = false; }); }, /**