Skip to content

Conversation

@rrahir
Copy link
Collaborator

@rrahir rrahir commented Nov 26, 2025

Description:

Currently, ODOO pivots computed measures are not properly updated upon
sheet structure modification. To be precise, their definition, which is
stored in the core plugin PivotCorePlugin is properly updated but the
runtime definition, stored in PivotUIPlugin, is not.

This occurs because the mecanism to invalidate the runtime definition
explicitely ignores the ODOO pivots. histoically, this was set up to
avoid useless reloading of ODOO pivots which could end up making server
calls but this logic is properly handled in the function onDefinitionChange.

We can see that in the case of spreadsheet pivots, we already
notify all plugins of such a change, but by "pure accident", as we
dispatch an "UPDATE_PIVOT" command at every range adaptation, regardless
of whether it was necessary or not. This means that the spreadsheet
pivots beneficiated of two mecanisms to update their runtime (in core,
an UPDATE_PIVOT, and the invalidateEvaluationCommands mecanism) which
means that invalidation work was done two times.

The investigation also led to the discovery of a missing check on the
command "ADD_PIVOT" which has been reported in https://www.odoo.com/odoo/2328/tasks/5360591

We also noted that there is a double handling of commands between the
handling of invalidateEvaluationCommands and the specific command
handlers in PivotUIPlugin. We could clean this up in master.

Note that additional tests regarding the Odoo pivots will be added in
Odoo repository to ensure the validity of the fix.
Task: 5358213

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

@robodoo
Copy link
Collaborator

robodoo commented Nov 26, 2025

Pull request status dashboard

@rrahir rrahir changed the title 18.0 fix measure update rar [FIX] pivot: Ensure computed measure range adaptation Nov 26, 2025
@rrahir rrahir force-pushed the 18.0-fix-measure-update-rar branch from df1d0ec to 7efa1f5 Compare November 26, 2025 10:11
Currently, ODOO pivots computed measures are not properly updated upon
sheet structure modification. To be precise, their definition, which is
stored in the core plugin `PivotCorePlugin` is properly updated but the
runtime definition, stored in `PivotUIPlugin`, is not.

This occurs because the mecanism to invalidate the runtime definition
explicitely ignores the ODOO pivots. histoically, this was set up to
avoid useless reloading of ODOO pivots which could end up making server
calls but this logic is properly handled in the function `onDefinitionChange`.

We can see that in the case of spreadsheet pivots, we already
notify all plugins of such a change, but by "pure accident", as we
dispatch an "UPDATE_PIVOT" command at every range adaptation, regardless
of whether it was necessary or not. This means that the spreadsheet
pivots beneficiated of two mecanisms to update their runtime (in core,
an UPDATE_PIVOT, and the `invalidateEvaluationCommands` mecanism) which
means that invalidation work was done two times.

The investigation also led to the discovery of a missing check on the
command "ADD_PIVOT" which has been reported in  https://www.odoo.com/odoo/2328/tasks/5360591

We also noted that there is a double handling of commands between the
handling of `invalidateEvaluationCommands` and the specific command
handlers in `PivotUIPlugin`. We could clean this up in master.

Note that additional tests regarding the Odoo pivots will be added in
Odoo repository to ensure the validity of the fix.

Task: 5358213
@rrahir rrahir force-pushed the 18.0-fix-measure-update-rar branch from 7efa1f5 to 9c32b21 Compare November 28, 2025 07:51
Copy link
Collaborator

@LucasLefevre LucasLefevre left a comment

Choose a reason for hiding this comment

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

robodoo r+

handle(cmd: Command) {
if (invalidateEvaluationCommands.has(cmd.type)) {
for (const pivotId of this.getters.getPivotIds()) {
if (!pivotRegistry.get(this.getters.getPivotCoreDefinition(pivotId).type).externalData) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

If I understand correctly, there's no bug in o-spreadsheet (all tests in this PR are ✔️ in without the diff in the code), but this is this line which prevents from updating odoo pivots ? and also the deepcopy

But then, are the tests introduced/changed here useful ?

@robodoo
Copy link
Collaborator

robodoo commented Nov 28, 2025

@rrahir @LucasLefevre because this PR has multiple commits, I need to know how to merge it:

  • merge to merge directly, using the PR as merge commit message
  • rebase-merge to rebase and merge, using the PR as merge commit message
  • rebase-ff to rebase and fast-forward

@LucasLefevre
Copy link
Collaborator

Ah non, je voulais pas r+ 😅
I just wanted to ask the question

@rrahir
Copy link
Collaborator Author

rrahir commented Nov 28, 2025

robodoo r-

@LucasLefevre I tried a first implementatioon which ended up breaking the evaluation (on undo/redo) and all the tests passed, I caught it by testing this morning in Odoo so I added a bit of coverage.
the test "references are adapted with sheet (https://github.com/odoo/o-spreadsheet/pull/7534/files#diff-75d3b99b661635620faf9ae3eb07a99dcb16898c41607c9b488d900b7aa27d50R1068) was changed because the sheet change impacted both the computed measure AND the pivot dataset, the latter creates an invalidation of the pivot runtime on its own (see SpreadsheetPivotCorePlugin.adaptRanges) which is why I tried to test the computed measure dependency only/

Copy link
Collaborator

@LucasLefevre LucasLefevre left a comment

Choose a reason for hiding this comment

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

robodoo r+

@rrahir
Copy link
Collaborator Author

rrahir commented Nov 28, 2025

robodoo rebase-ff

@robodoo
Copy link
Collaborator

robodoo commented Nov 28, 2025

Merge method set to rebase and fast-forward.

robodoo pushed a commit that referenced this pull request Nov 28, 2025
Task: 5358213
Part-of: #7534
Signed-off-by: Lucas Lefèvre (lul) <[email protected]>
robodoo pushed a commit that referenced this pull request Nov 28, 2025
Currently, ODOO pivots computed measures are not properly updated upon
sheet structure modification. To be precise, their definition, which is
stored in the core plugin `PivotCorePlugin` is properly updated but the
runtime definition, stored in `PivotUIPlugin`, is not.

This occurs because the mecanism to invalidate the runtime definition
explicitely ignores the ODOO pivots. histoically, this was set up to
avoid useless reloading of ODOO pivots which could end up making server
calls but this logic is properly handled in the function `onDefinitionChange`.

We can see that in the case of spreadsheet pivots, we already
notify all plugins of such a change, but by "pure accident", as we
dispatch an "UPDATE_PIVOT" command at every range adaptation, regardless
of whether it was necessary or not. This means that the spreadsheet
pivots beneficiated of two mecanisms to update their runtime (in core,
an UPDATE_PIVOT, and the `invalidateEvaluationCommands` mecanism) which
means that invalidation work was done two times.

The investigation also led to the discovery of a missing check on the
command "ADD_PIVOT" which has been reported in  https://www.odoo.com/odoo/2328/tasks/5360591

We also noted that there is a double handling of commands between the
handling of `invalidateEvaluationCommands` and the specific command
handlers in `PivotUIPlugin`. We could clean this up in master.

Note that additional tests regarding the Odoo pivots will be added in
Odoo repository to ensure the validity of the fix.

closes #7534

Task: 5358213
Signed-off-by: Lucas Lefèvre (lul) <[email protected]>
@robodoo robodoo closed this Nov 28, 2025
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