[FIX] board: remove Add to my dashboard in form views
Since the milk redesign, and the move of the "Add to my dashboard" action from the search view to the CogMenu (next to breadcrumbs), the action was available in all views, especially in form views, which isn't what we want. Adding a form view to the dashboard results in an empty form view (in creation) being displayed in the dashboard. Before milk, the form view naturally didn't allow to add to dashboard as it has no search view. This commit checks the view type to determine if the action must be available or not. Task 3552870 closes odoo/odoo#145534 X-original-commit: d01c75938948bd0e365d7ca1e4f518ce5b563f5c Signed-off-by: Jorge Pinna Puissant (jpp) <jpp@odoo.com>
This commit is contained in:
@@ -98,7 +98,10 @@ AddToBoard.components = { Dropdown };
|
||||
export const addToBoardItem = {
|
||||
Component: AddToBoard,
|
||||
groupNumber: 20,
|
||||
isDisplayed: ({ config }) => config.actionType === "ir.actions.act_window" && config.actionId,
|
||||
isDisplayed: ({ config }) => {
|
||||
const { actionType, actionId, viewType } = config;
|
||||
return actionType === "ir.actions.act_window" && actionId && viewType !== "form";
|
||||
},
|
||||
};
|
||||
|
||||
cogMenuRegistry.add("add-to-board", addToBoardItem, { sequence: 10 });
|
||||
|
||||
@@ -514,4 +514,38 @@ QUnit.module("Board", (hooks) => {
|
||||
await testUtils.fields.editInput(input, "Pipeline");
|
||||
await triggerEvent(input, null, "keydown", { key: "Enter" });
|
||||
});
|
||||
|
||||
QUnit.test("Add to my dashboard is not available in form views", async function (assert) {
|
||||
serverData.views = {
|
||||
"partner,false,list": '<list><field name="foo"/></list>',
|
||||
"partner,false,form": '<form><field name="foo"/></form>',
|
||||
"partner,false,search": "<search></search>",
|
||||
};
|
||||
|
||||
const webClient = await createWebClient({ serverData });
|
||||
await doAction(webClient, {
|
||||
id: 1,
|
||||
res_model: "partner",
|
||||
type: "ir.actions.act_window",
|
||||
context: { fire: "on the bayou" },
|
||||
views: [
|
||||
[false, "list"],
|
||||
[false, "form"],
|
||||
],
|
||||
});
|
||||
|
||||
assert.containsOnce(target, ".o_list_view", "should display the list view");
|
||||
|
||||
// sanity check
|
||||
await click(target, ".o_cp_action_menus .dropdown-toggle");
|
||||
assert.containsOnce(target, ".o_cp_action_menus .dropdown-menu .o_add_to_board");
|
||||
|
||||
// open form view
|
||||
await click(target.querySelector(".o_data_cell"));
|
||||
assert.containsOnce(target, ".o_form_view");
|
||||
|
||||
await click(target, ".o_cp_action_menus .dropdown-toggle");
|
||||
assert.containsOnce(target, ".o_cp_action_menus .dropdown-menu");
|
||||
assert.containsNone(target, ".o_cp_action_menus .dropdown-menu .o_add_to_board");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user