odoo/o-spreadsheet#7564

Created by fw-bot
Merged at 4777025ffe1e675fb5ea96335739eb88fc6286c6

Statuses:

label
odoo:saas-18.3-18.0-fix-measure-update-rar-480929-fw
head
84d3c3312a14e960d030fa7982a47d83fa0dc3d5
merged
4 hours ago by BI, Rémi Rahir (rar)
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

Forward-Port-Of: #7560
Forward-Port-Of: #7534