[FIX] web: navbar: set action id in menu href

Before this commit, the href attribute of menu elements didn't
contain the "action=xx" part but only the id of the menu.

closes odoo/odoo#87570

X-original-commit: 6b8242ee1918b784dfdb2160cca6df1c165a824b
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
This commit is contained in:
Waleed Mohsen
2022-03-30 16:34:04 +02:00
committed by Aaron Bohy
parent f6a9c2868c
commit c31423a756
2 changed files with 15 additions and 2 deletions
@@ -180,8 +180,8 @@ export class NavBar extends Component {
getMenuItemHref(payload) {
const parts = [`menu_id=${payload.id}`];
if (payload.action) {
parts.push(`action=${payload.action.split(",")[1]}`);
if (payload.actionID) {
parts.push(`action=${payload.actionID}`);
}
return "#" + parts.join("&");
}
@@ -70,6 +70,19 @@ QUnit.test("dropdown menu can be toggled", async (assert) => {
assert.containsNone(dropdown, ".dropdown-menu");
});
QUnit.test("href attribute on apps menu items", async (assert) => {
baseConfig.serverData.menus = {
root: { id: "root", children: [1], name: "root", appID: "root" },
1: { id: 1, children: [2], name: "My app", appID: 1, actionID: 339 },
};
const env = await makeTestEnv(baseConfig);
await mount(NavBar, target, { env });
const appsMenu = target.querySelector(".o_navbar_apps_menu");
await click(appsMenu, "button.dropdown-toggle");
const dropdownItem = target.querySelector(".o_navbar_apps_menu .dropdown-item");
assert.strictEqual(dropdownItem.getAttribute("href"), "#menu_id=1&action=339");
});
QUnit.test("data-menu-xmlid attribute on AppsMenu items", async (assert) => {
baseConfig.serverData.menus = {
root: { id: "root", children: [1, 2], name: "root", appID: "root" },