[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>
This commit is contained in:
co-authored by
fleodoo
aab-odoo
parent
1e28e7274b
commit
35b4b6b745
@@ -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}],
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user