Skip to content

Commit a9afde9

Browse files
pro-odoorrahir
authored andcommitted
[FIX] menu_items: fix sequence calculation for pivot data sources
Depending on the number of pivot tables, the pivot items could be displayed after other items (e.g. Re-insert dynamic pivot) in the topbar menu. Practically, the number of pivots to observe the issue is not realistic, as it requires more than 970 pivots. But the issue can be observed easily with 25 lists in Odoo. To fix the issue, we need to compute the sequence with decimal numbers, to ensure that the pivot items are always between the first sequence (50) and sequence + 1 (51). closes #7061 Task: 5025230 X-original-commit: 1462cbc Signed-off-by: Rémi Rahir (rar) <rar@odoo.com> Signed-off-by: Pierre Rousseau (pro) <pro@odoo.com>
1 parent 90d1bb3 commit a9afde9

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/actions/data_actions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export const splitToColumns: ActionSpec = {
7373
export const reinsertDynamicPivotMenu: ActionSpec = {
7474
id: "reinsert_dynamic_pivot",
7575
name: _t("Re-insert dynamic pivot"),
76-
sequence: 1020,
76+
sequence: 60,
7777
icon: "o-spreadsheet-Icon.INSERT_PIVOT",
7878
children: [ACTIONS.REINSERT_DYNAMIC_PIVOT_CHILDREN],
7979
isVisible: (env) =>
@@ -83,7 +83,7 @@ export const reinsertDynamicPivotMenu: ActionSpec = {
8383
export const reinsertStaticPivotMenu: ActionSpec = {
8484
id: "reinsert_static_pivot",
8585
name: _t("Re-insert static pivot"),
86-
sequence: 1020,
86+
sequence: 70,
8787
icon: "o-spreadsheet-Icon.INSERT_PIVOT",
8888
children: [ACTIONS.REINSERT_STATIC_PIVOT_CHILDREN],
8989
isVisible: (env) =>

src/registries/menus/topbar_menu_registry.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -468,8 +468,9 @@ topbarMenuRegistry
468468
sequence: 40,
469469
separator: true,
470470
})
471-
.addChild("data_sources_data", ["data"], (env) => {
471+
.addChild("pivot_data_sources", ["data"], (env) => {
472472
const sequence = 50;
473+
const numberOfPivots = env.model.getters.getPivotIds().length;
473474
return env.model.getters.getPivotIds().map((pivotId, index) => {
474475
const highlightProvider = {
475476
get highlights() {
@@ -479,7 +480,7 @@ topbarMenuRegistry
479480
return {
480481
id: `item_pivot_${env.model.getters.getPivotFormulaId(pivotId)}`,
481482
name: env.model.getters.getPivotDisplayName(pivotId),
482-
sequence: sequence + index,
483+
sequence: sequence + index / numberOfPivots,
483484
isReadonlyAllowed: true,
484485
execute: (env) => env.openSidePanel("PivotSidePanel", { pivotId }),
485486
isEnabled: (env) => !env.isSmall,

0 commit comments

Comments
 (0)