diff options
| author | Lucas Lefèvre <lul@odoo.com> | 2020-07-30 10:20:29 +0000 |
|---|---|---|
| committer | Lucas Lefèvre <lul@odoo.com> | 2020-07-30 13:45:07 +0000 |
| commit | 35b4b6b745a5c3d9df63a4a3e6ff2659126aa0ad (patch) | |
| tree | 05f51f27f0268fafac147963c0da89709973d677 /addons | |
| parent | 1e28e7274b8ab006b6723b5a33bc5c399f6c4613 (diff) | |
[FIX] web: Close dialog when clicking button with close attribute
In a dialog, a button with `close="1"` should close the dialog when clicked.
It currently only works if the dialog is a subview.
closes odoo/odoo#55200
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Co-authored-by: fleodoo <fle@odoo.com>
Co-authored-by: aab-odoo <aab@odoo.com>
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/web/static/src/js/chrome/action_manager.js | 2 | ||||
| -rw-r--r-- | addons/web/static/tests/chrome/action_manager_tests.js | 59 |
2 files changed, 60 insertions, 1 deletions
diff --git a/addons/web/static/src/js/chrome/action_manager.js b/addons/web/static/src/js/chrome/action_manager.js index aee954342fa..bdcc93e022a 100644 --- a/addons/web/static/src/js/chrome/action_manager.js +++ b/addons/web/static/src/js/chrome/action_manager.js @@ -393,7 +393,7 @@ var ActionManager = Widget.extend({ return dialog.open().opened(function () { self.currentDialogController = controller; - + widget.setParent(dialog); dom.append(dialog.$el, widget.$el, { in_DOM: true, callbacks: [{widget: dialog}, {widget: controller.widget}], diff --git a/addons/web/static/tests/chrome/action_manager_tests.js b/addons/web/static/tests/chrome/action_manager_tests.js index 02ba1d2472d..971c5effb98 100644 --- a/addons/web/static/tests/chrome/action_manager_tests.js +++ b/addons/web/static/tests/chrome/action_manager_tests.js @@ -3852,6 +3852,65 @@ QUnit.module('ActionManager', { actionManager.destroy(); }); + QUnit.test("Button with `close` attribute closes dialog", async function (assert) { + assert.expect(2); + const actions = [ + { + id: 4, + name: "Partners Action 4", + res_model: "partner", + type: "ir.actions.act_window", + views: [[false, "form"]], + }, + { + id: 5, + name: "Create a Partner", + res_model: "partner", + target: "new", + type: "ir.actions.act_window", + views: [["view_ref", "form"]], + }, + ]; + + const actionManager = await createActionManager({ + actions, + archs: { + "partner,false,form": ` + <form> + <header> + <button string="Open dialog" name="5" type="action"/> + </header> + </form> + `, + "partner,view_ref,form": ` + <form> + <footer> + <button string="I close the dialog" name="some_method" type="object" close="1"/> + </footer> + </form> + `, + "partner,false,search": "<search></search>", + }, + data: this.data, + mockRPC: async function (route, args) { + if ( + route === "/web/dataset/call_button" && + args.method === "some_method" + ) { + return { tag: "display_notification", type: "ir.actions.client" }; + } + return this._super(...arguments); + }, + }); + + await actionManager.doAction(4); + await testUtils.dom.click(`button[name="5"]`); + 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('on_attach_callback is called for actions in target="new"', async function (assert) { assert.expect(4); |
