odoo/o-spreadsheet#7534

Created by BI, Rémi Rahir (rar)
Merged at cd6c2d8de824e3812fc440926ad49026dcb46527

Statuses:

label
odoo:18.0-fix-measure-update-rar
head
9c32b217f04630a770bda7531bc4570635680c0f
merged
11 hours ago by BI, Lucas Lefèvre (lul)
odoo/o-spreadsheet
18.0 #7534
saas-18.2 #7560
saas-18.3 #7564
saas-18.4 #7565
19.0 #7566
master #7567

[FIX] pivot: Ensure computed measure range adaptation

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