Skip to content

[FIX] pivot: carry forward running totals for missing date buckets#7714

Closed
dhrp-odoo wants to merge 1 commit intomasterfrom
19.0-fix-pivot-running-total-dhrp
Closed

[FIX] pivot: carry forward running totals for missing date buckets#7714
dhrp-odoo wants to merge 1 commit intomasterfrom
19.0-fix-pivot-running-total-dhrp

Conversation

@dhrp-odoo
Copy link
Contributor

Description:

When a measure is displayed as "running total" and the pivot is grouped by a date granularity (month/day/etc), PIVOT.VALUE returned an empty value for a requested bucket that does not exist in the pivot. This happened because the running-total cache only stores values for materialized pivot buckets, so a missing date key had no direct lookup.

With this commit, for date/datetime dimensions, we build an ordered index of existing buckets per secondary domain and running-total group, and use a binary search to find the nearest previous bucket. If found, we return its cumulative value (carry-forward); if the requested bucket is before the first one, we return empty.

Task: 5420999

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 Jan 5, 2026

Pull request status dashboard

@dhrp-odoo dhrp-odoo force-pushed the 19.0-fix-pivot-running-total-dhrp branch from 4e455ef to 15e98b2 Compare January 16, 2026 13:16
Copy link
Contributor

@hokolomopo hokolomopo left a comment

Choose a reason for hiding this comment

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

It looks way simpler now ! A small comment still 🙂

@dhrp-odoo dhrp-odoo force-pushed the 19.0-fix-pivot-running-total-dhrp branch from 15e98b2 to a5fdfa4 Compare January 19, 2026 10:19
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.

LGTM, thanks! 👌

Could you slightly increase the test coverage ? It's not straight forward, so the better it's tested, the better it is :)

@dhrp-odoo dhrp-odoo force-pushed the 19.0-fix-pivot-running-total-dhrp branch 2 times, most recently from c472dd4 to 9c5a5e7 Compare February 3, 2026 09:25
@dhrp-odoo dhrp-odoo changed the base branch from 19.0 to master February 3, 2026 09:26
@dhrp-odoo dhrp-odoo force-pushed the 19.0-fix-pivot-running-total-dhrp branch from 9c5a5e7 to 8011e63 Compare February 3, 2026 11:16
When a measure is displayed as "running total" and the pivot is grouped by a
date/datetime granularity, PIVOT.VALUE could return an empty value when the
requested bucket is not materialized in the pivot.

This happened because the running-total cache only stores values for existing
pivot buckets, so missing date keys had no direct lookup.

For date/datetime dimensions, when a running-total lookup misses, traverse the
row/col tree to find the nearest previous bucket within the same running-total
group (respecting dimension order) and return its cumulative value. If the
bucket is before the first one, return empty.

Task: 5420999
@dhrp-odoo dhrp-odoo force-pushed the 19.0-fix-pivot-running-total-dhrp branch from 8011e63 to 2d6211d Compare February 6, 2026 06:37
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+

robodoo pushed a commit that referenced this pull request Feb 6, 2026
When a measure is displayed as "running total" and the pivot is grouped by a
date/datetime granularity, PIVOT.VALUE could return an empty value when the
requested bucket is not materialized in the pivot.

This happened because the running-total cache only stores values for existing
pivot buckets, so missing date keys had no direct lookup.

For date/datetime dimensions, when a running-total lookup misses, traverse the
row/col tree to find the nearest previous bucket within the same running-total
group (respecting dimension order) and return its cumulative value. If the
bucket is before the first one, return empty.

closes #7714

Task: 5420999
Signed-off-by: Lucas Lefèvre (lul) <lul@odoo.com>
@robodoo robodoo added the 19.2 label Feb 6, 2026
@robodoo robodoo closed this Feb 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants