Skip to content

Commit

Permalink
fix pivot insertion handler
Browse files Browse the repository at this point in the history
  • Loading branch information
rrahir authored and pro-odoo committed Apr 22, 2024
1 parent 7dcc8e4 commit 248d623
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
5 changes: 5 additions & 0 deletions src/helpers/pivot/pivot_helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,11 @@ export const ALL_PERIODS = {
month: _t("Month"),
week: _t("Week"),
day: _t("Day"),
year_number: _t("Year"),
quarter_number: _t("Quarter"),
month_number: _t("Month"),
iso_week_number: _t("Week"),
day_of_month: _t("Day of Month"),
};

const DATE_FIELDS = ["date", "datetime"];
Expand Down
10 changes: 4 additions & 6 deletions src/plugins/ui_feature/insert_pivot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ export class InsertPivotPlugin extends UIPlugin {
if (getZoneArea(this.getters.getSelectedZone()) === 1) {
this.selection.selectTableAroundSelection();
}

const currentSheetId = this.getters.getActiveSheetId();
this.dispatch("ADD_PIVOT", {
pivotId,
pivot: {
zone: this.getters.getSelectedZone(),
sheetId,
sheetId: currentSheetId,
columns: [],
rows: [],
measures: [],
Expand All @@ -34,17 +34,15 @@ export class InsertPivotPlugin extends UIPlugin {
});

const position =
this.getters
.getSheetIds()
.findIndex((sheetId) => sheetId === this.getters.getActiveSheetId()) + 1;
this.getters.getSheetIds().findIndex((sheetId) => sheetId === currentSheetId) + 1;
const formulaId = this.getters.getPivotFormulaId(pivotId);
this.dispatch("CREATE_SHEET", {
sheetId,
name: _t("Pivot #%s", formulaId),
position,
});
this.dispatch("ACTIVATE_SHEET", {
sheetIdFrom: this.getters.getActiveSheetId(),
sheetIdFrom: currentSheetId,
sheetIdTo: sheetId,
});
this.dispatch("UPDATE_CELL", {
Expand Down

0 comments on commit 248d623

Please sign in to comment.