From bce6aa351b3acb9f5eac2eca52a20e313641e747 Mon Sep 17 00:00:00 2001 From: David Monjoie Date: Mon, 3 Jun 2019 12:50:56 +0000 Subject: [IMP] web: rejected click handlers should not close the dialog Prior to this commit, there was no clean way to have a button triggering asynchronous work (like asking user for confirmaton for example) and close or not close the modal according to the user choice. Your options were: 1. Swallow the pill and just accept that the modal will close even if the user chose not to undertake the action. 2. Set the `close` parameter of the button to false and handle the conditional closing by yourself from outside the dialog. This commit introduces a way to tell the form view dialog that the action has not been processed correctly and that the modal should not be closed by returning a rejected promise. Prior behavior can still be obtained (close no matter the result) by having the handler not returning a promise at all. closes odoo/odoo#33837 Signed-off-by: Aaron Bohy (aab) --- addons/web/static/src/js/core/dialog.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/web/static/src/js/core/dialog.js') diff --git a/addons/web/static/src/js/core/dialog.js b/addons/web/static/src/js/core/dialog.js index cd76ec770bb..bb522992c2f 100644 --- a/addons/web/static/src/js/core/dialog.js +++ b/addons/web/static/src/js/core/dialog.js @@ -304,7 +304,7 @@ var Dialog = Widget.extend({ } if (buttonData.close) { self.onForceClose = false; - Promise.resolve(def).then(self.close.bind(self)).guardedCatch(self.close.bind(self)); + Promise.resolve(def).then(self.close.bind(self)); } }); if (self.technical) { -- cgit v1.2.3