[FIX] web: Incorrect navbar when leaving an invalid form view
Before this commit, when trying to change the menu from an invalid form view, you would stay on the form view but the navbar would be modified to dispaly the menu you had selected. How to reproduce: - Go to a form view - Edit the fields so that the record is invalid - Change the menu using the menu app or the palette command Before this commit: The form view has not changed but the navbar has been modified, it shows the menu you selected. After this commit: The form view and the navbar have not changed. closes odoo/odoo#109460 X-original-commit: bd7e36edcd2f9d33a72cc25b030f91c20da78387 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
This commit is contained in:
@@ -1240,7 +1240,7 @@ function makeActionManager(env) {
|
||||
if (action.target !== "new") {
|
||||
const canProceed = await clearUncommittedChanges(env);
|
||||
if (!canProceed) {
|
||||
return;
|
||||
return new Promise(() => {});
|
||||
}
|
||||
}
|
||||
return _executeActWindowAction(action, options);
|
||||
|
||||
@@ -1702,6 +1702,73 @@ QUnit.module("Views", (hooks) => {
|
||||
assert.hasClass(target.querySelector(".o_notebook .nav-link"), "active");
|
||||
});
|
||||
|
||||
QUnit.test(
|
||||
"trying to leave an invalid form view should not change the navbar",
|
||||
async function (assert) {
|
||||
serverData.menus = {
|
||||
root: { id: "root", children: [1, 2], name: "root", appID: "root" },
|
||||
1: { id: 1, children: [], name: "App0", appID: 1, xmlid: "menu_3", actionID: 1 },
|
||||
2: { id: 2, children: [], name: "App1", appID: 2, xmlid: "menu_3", actionID: 2 },
|
||||
};
|
||||
serverData.views = {
|
||||
"partner,false,form": `
|
||||
<form>
|
||||
<sheet>
|
||||
<field name="display_name" required="1"/>
|
||||
<field name="foo"/>
|
||||
</sheet>
|
||||
</form>`,
|
||||
"product,false,list": '<tree><field name="display_name"/></tree>',
|
||||
"product,false,search": "<search></search>",
|
||||
"partner,false,search": "<search></search>",
|
||||
};
|
||||
|
||||
serverData.actions = {
|
||||
1: {
|
||||
id: 1,
|
||||
name: "Partner",
|
||||
res_model: "partner",
|
||||
type: "ir.actions.act_window",
|
||||
views: [[false, "form"]],
|
||||
},
|
||||
2: {
|
||||
id: 2,
|
||||
name: "Product",
|
||||
res_model: "product",
|
||||
type: "ir.actions.act_window",
|
||||
views: [[false, "list"]],
|
||||
},
|
||||
};
|
||||
|
||||
const target = getFixture();
|
||||
const webClient = await createWebClient({ serverData });
|
||||
|
||||
await doAction(webClient, 1);
|
||||
assert.strictEqual(
|
||||
target.querySelector(".o_main_navbar .o_menu_brand").textContent,
|
||||
"App0"
|
||||
);
|
||||
|
||||
await editInput(target, "[name='foo'] input", "blop");
|
||||
await click(target, ".o_navbar_apps_menu button");
|
||||
await click(target, ".o_navbar_apps_menu .dropdown-item[data-section='2']");
|
||||
await nextTick();
|
||||
assert.strictEqual(
|
||||
target.querySelector(".o_main_navbar .o_menu_brand").textContent,
|
||||
"App0"
|
||||
);
|
||||
|
||||
await editInput(target, "[name='display_name'] input", "blop");
|
||||
await click(target, ".o_navbar_apps_menu button");
|
||||
await click(target, ".o_navbar_apps_menu .dropdown-item[data-section='2']");
|
||||
await nextTick();
|
||||
assert.strictEqual(
|
||||
target.querySelector(".o_main_navbar .o_menu_brand").textContent,
|
||||
"App1"
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
QUnit.test("rendering stat buttons with action", async function (assert) {
|
||||
assert.expect(3);
|
||||
|
||||
|
||||
@@ -15357,7 +15357,8 @@ QUnit.module("Views", (hooks) => {
|
||||
|
||||
await click(target.querySelector(".o_data_cell"));
|
||||
await editInput(target, '.o_data_cell [name="foo"] input', "");
|
||||
await doAction(webClient, 2);
|
||||
doAction(webClient, 2);
|
||||
await nextTick();
|
||||
assert.deepEqual(
|
||||
[...target.querySelectorAll(".o_data_cell")].map((el) => el.textContent),
|
||||
["", "blip", "gnap", "blip"]
|
||||
|
||||
Reference in New Issue
Block a user