Skip to content

[FIX] pivot: unused pivot detection #8539

Open
hokolomopo wants to merge 2 commits into
18.0from
18.0-fix-unused-pivot-adrm
Open

[FIX] pivot: unused pivot detection #8539
hokolomopo wants to merge 2 commits into
18.0from
18.0-fix-unused-pivot-adrm

Conversation

@hokolomopo
Copy link
Copy Markdown
Contributor

Description:

[FIX] pivot: unused pivot detection with composed formula

If a formula has two pivots (eg. =PIVOT(1) + PIVOT(2)), the
second pivot will not be detected as used.

[FIX] pivot: unused pivot detection with calculated measure

If a pivot has a calculated measure that refers to a second pivot,
the second pivot is not detected as used. This commit fixes that.

Note: the fix does not fix 100% of the issues. A pivot only referenced
in other places (eg. in a CF rule formula) will still not be
detected as used. But checking every other place the pivot can be
referenced is expensive and error-prone. That may be done in master.

Task: 6105894

review checklist

  • feature is organized in plugin, or UI components
  • support of duplicate sheet (deep copy)
  • in model/core: ranges are Range object, and can be adapted (adaptRanges)
  • in model/UI: ranges are strings (to show the user)
  • undo-able commands (uses this.history.update)
  • multiuser-able commands (has inverse commands and transformations where needed)
  • new/updated/removed commands are documented
  • exportable in excel
  • translations (_t("qmsdf %s", abc))
  • unit tested
  • clean commented code
  • track breaking changes
  • doc is rebuild (npm run doc)
  • status is correct in Odoo

hokolomopo added 2 commits May 4, 2026 10:09
If a pivot has a calculated measure that refers to a second pivot,
the second pivot is not detected as used. This commit fixes that.

Note: the fix does not fix 100% of the issues. A pivot only referenced
in other places (eg. in a CF rule formula) will still not be
detected as used. But checking every other place the pivot can be
referenced is expensive and error-prone. That may be done in master.

Task: 6105894
If a formula has two pivots (eg. `=PIVOT(1) + PIVOT(2)`), the
second pivot will not be detected as used.

Task: 6105894
@robodoo
Copy link
Copy Markdown
Collaborator

robodoo commented May 4, 2026

Pull request status dashboard

});
});

test("Pivot highlights works with multiple pivot formulas in the same cell", () => {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this test is duplicated with the one above

Comment on lines 136 to 140
const cell = this.getters.getCorrespondingFormulaCell(position);
if (cell && cell.isFormula) {
const pivotFunction = this.getFirstPivotFunction(
position.sheetId,
cell.compiledFormula.tokens
);
if (pivotFunction) {
const pivotId = pivotFunction.args[0]?.toString();
return pivotId && this.getters.getPivotId(pivotId);
}
return this.getPivotIdsFromPosition(position)[0];
}
return undefined;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be simplified to

getPivotIdFromPosition(position: CellPosition): UID | undefined {
  return this.getPivotIdsFromPosition(position)[0];
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants