From c14622fcd3a32ad8f48a5ad21453045e010d1cb9 Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Wed, 17 Feb 2021 09:27:48 +0000 Subject: [PATCH] [FIX] web: correctly close confirm dialog Let's assume the following scenario: - have an action in target new (e.g. a form view) - in the dialog, have an action/object button with confirm attribute - when clicking on that button, a confirm dialog opens - if validated, the following action returned by the server is again an action in target new Before this commit, the confirm dialog remained in the DOM. This issue occurred because it's parent wasn't correctly set (wrong use of `this`), so when the first dialog was destroyed, the confirm dialog wasn't automatically destroyed in turn. OPW~2440712 closes odoo/odoo#66597 X-original-commit: 98f9cb4f692a15494cd8ef298673fe1c949c423c Signed-off-by: Jorge Pinna Puissant (jpp) --- .../src/js/views/form/form_controller.js | 2 +- .../tests/chrome/action_manager_tests.js | 52 +++++++++++++++++++ 2 files changed, 53 insertions(+), 1 deletion(-) diff --git a/addons/web/static/src/js/views/form/form_controller.js b/addons/web/static/src/js/views/form/form_controller.js index bf5829a0593..063ef268d9b 100644 --- a/addons/web/static/src/js/views/form/form_controller.js +++ b/addons/web/static/src/js/views/form/form_controller.js @@ -513,7 +513,7 @@ var FormController = BasicController.extend({ var attrs = ev.data.attrs; if (attrs.confirm) { def = new Promise(function (resolve, reject) { - Dialog.confirm(this, attrs.confirm, { + Dialog.confirm(self, attrs.confirm, { confirm_callback: saveAndExecuteAction, }).on("closed", null, resolve); }); diff --git a/addons/web/static/tests/chrome/action_manager_tests.js b/addons/web/static/tests/chrome/action_manager_tests.js index 7af03e92ae6..af335509afa 100644 --- a/addons/web/static/tests/chrome/action_manager_tests.js +++ b/addons/web/static/tests/chrome/action_manager_tests.js @@ -4031,6 +4031,58 @@ QUnit.module('ActionManager', { assert.strictEqual($(".modal").length, 1, "It should display a modal"); await testUtils.dom.click(`button[name="some_method"]`); assert.strictEqual($(".modal").length, 0, "It should have closed the modal"); + + actionManager.destroy(); + }); + + QUnit.test('can execute act_window actions in target="new"', async function (assert) { + assert.expect(5); + + this.actions.push({ + id: 999, + name: 'A window action', + res_model: 'partner', + target: 'new', + type: 'ir.actions.act_window', + views: [[999, 'form']], + }); + this.archs['partner,999,form'] = ` +
+