[FIX] board: prevent add to dashboard with no actionID
Steps to reproduce: - Go to Purchase -> Reporting -> Dashboard - click on the "expand" arrows of the pivot view - favorites - add to dashboard Bug: adding a view with no actionID causes the dashboard to crash on load this [commit] prevents adding a view with no actionID Fix: added a default value of False to add_to_dashboard actionId only display the option to add_to_dashboard for views that have actionId opw-2965036 [commit]:https://github.com/odoo-dev/odoo/commit/7180d948f084d4f68d1660cb884c95aaf41288fa closes odoo/odoo#106093 X-original-commit: ff926a5b4390b38db339440c18dd2d5380df7d61 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com> Signed-off-by: Walid Hanniche (waha) <waha@odoo.com>
This commit is contained in:
@@ -52,7 +52,7 @@ export class AddToBoard extends Component {
|
||||
};
|
||||
|
||||
const result = await this.rpc("/board/add_to_dashboard", {
|
||||
action_id: this.env.config.actionId,
|
||||
action_id: this.env.config.actionId || false,
|
||||
context_to_save: contextToSave,
|
||||
domain,
|
||||
name: this.state.name,
|
||||
@@ -93,10 +93,10 @@ export class AddToBoard extends Component {
|
||||
AddToBoard.template = "board.AddToBoard";
|
||||
AddToBoard.components = { Dropdown };
|
||||
|
||||
const addToBoardItem = {
|
||||
export const addToBoardItem = {
|
||||
Component: AddToBoard,
|
||||
groupNumber: 4,
|
||||
isDisplayed: ({ config }) => config.actionType === "ir.actions.act_window",
|
||||
isDisplayed: ({ config }) => config.actionType === "ir.actions.act_window" && config.actionId,
|
||||
};
|
||||
|
||||
favoriteMenuRegistry.add("add-to-board", addToBoardItem, { sequence: 10 });
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/** @odoo-module **/
|
||||
|
||||
import { AddToBoard } from "@board/add_to_board/add_to_board";
|
||||
import { addToBoardItem } from "@board/add_to_board/add_to_board";
|
||||
import {
|
||||
click,
|
||||
getFixture,
|
||||
@@ -84,11 +84,7 @@ QUnit.module("Board", (hooks) => {
|
||||
LegacyFavoriteMenu.registry.add("add-to-board-menu", LegacyAddToBoard, 10);
|
||||
favoriteMenuRegistry.add(
|
||||
"add-to-board",
|
||||
{
|
||||
Component: AddToBoard,
|
||||
groupNumber: 4,
|
||||
isDisplayed: ({ config }) => config.actionType === "ir.actions.act_window",
|
||||
},
|
||||
addToBoardItem,
|
||||
{ sequence: 10 }
|
||||
);
|
||||
serverData = { models };
|
||||
@@ -281,6 +277,36 @@ QUnit.module("Board", (hooks) => {
|
||||
await testUtils.dom.click(target.querySelector(".o_add_to_board .dropdown-menu button"));
|
||||
});
|
||||
|
||||
QUnit.test("add to dashboard with no action id", async function (assert) {
|
||||
assert.expect(2);
|
||||
|
||||
serverData.views = {
|
||||
"partner,false,pivot": '<pivot><field name="foo"/></pivot>',
|
||||
"partner,false,search": '<search/>',
|
||||
};
|
||||
registry.category("services").add("user", makeFakeUserService());
|
||||
const webClient = await createWebClient({ serverData });
|
||||
|
||||
await doAction(webClient, {
|
||||
id: false,
|
||||
res_model: "partner",
|
||||
type: "ir.actions.act_window",
|
||||
views: [[false, "pivot"]],
|
||||
});
|
||||
await toggleFavoriteMenu(target);
|
||||
assert.containsNone(target, ".o_add_to_board");
|
||||
|
||||
// Sanity check
|
||||
await doAction(webClient, {
|
||||
id: 1,
|
||||
res_model: "partner",
|
||||
type: "ir.actions.act_window",
|
||||
views: [[false, "pivot"]],
|
||||
});
|
||||
await toggleFavoriteMenu(target);
|
||||
assert.containsOnce(target, ".o_add_to_board");
|
||||
});
|
||||
|
||||
QUnit.test(
|
||||
"correctly save the time ranges of a reporting view in comparison mode",
|
||||
async function (assert) {
|
||||
|
||||
Reference in New Issue
Block a user