Skip to content

Commit e093ffb

Browse files
committed
[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 #6993 Task: 5025230 Signed-off-by: Rémi Rahir (rar) <rar@odoo.com>
1 parent e726d26 commit e093ffb

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
@@ -72,7 +72,7 @@ export const splitToColumns: ActionSpec = {
7272
export const reinsertDynamicPivotMenu: ActionSpec = {
7373
id: "reinsert_dynamic_pivot",
7474
name: _t("Re-insert dynamic pivot"),
75-
sequence: 1020,
75+
sequence: 60,
7676
icon: "o-spreadsheet-Icon.INSERT_PIVOT",
7777
children: [ACTIONS.REINSERT_DYNAMIC_PIVOT_CHILDREN],
7878
isVisible: (env) =>
@@ -82,7 +82,7 @@ export const reinsertDynamicPivotMenu: ActionSpec = {
8282
export const reinsertStaticPivotMenu: ActionSpec = {
8383
id: "reinsert_static_pivot",
8484
name: _t("Re-insert static pivot"),
85-
sequence: 1020,
85+
sequence: 70,
8686
icon: "o-spreadsheet-Icon.INSERT_PIVOT",
8787
children: [ACTIONS.REINSERT_STATIC_PIVOT_CHILDREN],
8888
isVisible: (env) =>

src/registries/menus/topbar_menu_registry.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -461,8 +461,9 @@ topbarMenuRegistry
461461
sequence: 40,
462462
separator: true,
463463
})
464-
.addChild("data_sources_data", ["data"], (env) => {
464+
.addChild("pivot_data_sources", ["data"], (env) => {
465465
const sequence = 50;
466+
const numberOfPivots = env.model.getters.getPivotIds().length;
466467
return env.model.getters.getPivotIds().map((pivotId, index) => {
467468
const highlightProvider = {
468469
get highlights() {
@@ -472,7 +473,7 @@ topbarMenuRegistry
472473
return {
473474
id: `item_pivot_${env.model.getters.getPivotFormulaId(pivotId)}`,
474475
name: env.model.getters.getPivotDisplayName(pivotId),
475-
sequence: sequence + index,
476+
sequence: sequence + index / numberOfPivots,
476477
execute: (env) => env.openSidePanel("PivotSidePanel", { pivotId }),
477478
onStartHover: (env) => env.getStore(HighlightStore).register(highlightProvider),
478479
onStopHover: (env) => env.getStore(HighlightStore).unRegister(highlightProvider),

0 commit comments

Comments
 (0)