Skip to content

[16.0][ADD] mis_builder_hierarchy: auto-expand hierarchical source data#736

Open
n3n wants to merge 4 commits into
16.0from
16.0-imp-mis_builder-hierarchical-row
Open

[16.0][ADD] mis_builder_hierarchy: auto-expand hierarchical source data#736
n3n wants to merge 4 commits into
16.0from
16.0-imp-mis_builder-hierarchical-row

Conversation

@n3n
Copy link
Copy Markdown
Member

@n3n n3n commented May 13, 2026

Summary

New module mis_builder_hierarchy that extends mis_builder to render account-detail rows as a tree whenever the source model exposes a self-referencing parent_id (e.g. account.analytic.account). Parent rows are auto-created by walking the parent chain from each leaf account that AEP returned, values are aggregated bottom-up (own + sum of descendants), and the OWL widget, QWeb PDF, and XLSX exporters all honor row depth via indentation and an expand/collapse caret. Achieved without forking upstream mis_builder — uses Odoo _inherit for the model layer and minimal monkey-patches on the plain-Python KpiMatrix / KpiMatrixRow classes.

Two new opt-in fields on mis.report.kpi: auto_expand_accounts_hierarchical (toggle) and auto_expand_accounts_rollup (sum / none).

Test plan

  • Install: ./odoo-bin -d <db> -i mis_builder_hierarchy --stop-after-init
  • On a KPI with Display details by account on an analytic source, enable Expand as hierarchy and verify parent rows appear with rolled-up values
  • Click caret to collapse/expand and confirm only descendants hide
  • Export to PDF and XLSX and confirm indent matches the on-screen tree
  • Confirm a KPI without the new flag still renders as before (no regression)

n3n added 4 commits May 13, 2026 09:23
Adds a new module that extends mis_builder to render account-detail rows
as a tree when the source model exposes a parent_id (e.g.
account.analytic.account). Parent rows are created on the fly by walking
the parent chain from each leaf account; their values are aggregated
bottom-up (sum of own value plus descendants), and the OWL widget, QWeb
PDF and XLSX exporters all honor the row depth with indentation and
expand/collapse controls.
…m style

Address review feedback:

- Drop ad-hoc _hierarchy_level dict key on style_props; instead fold the
  computed depth into style_props.indent_level, which upstream
  to_css_style / to_xlsx_style already render. Removes the
  mis.report.style override and the QWeb PDF inherit entirely.
- Replace BFS browse loop with a single parent_path read (one or two
  queries regardless of tree depth).
- Cache the children-by-parent map per KPI on the matrix; iter_rows and
  as_dict reuse it instead of rebuilding.
- Drop the compute_sums and _compute_matrix patches; rely on the single
  compute_comparisons pre-hook (which always runs before compute_sums
  in upstream) plus the idempotency flag.
- Memoize OWL hiddenKeys keyed on body+collapsed identity (O(N) per
  toggle instead of O(N²)).
- Switch auto_expand_accounts_rollup from Selection to Boolean.
- Add OCA manifest fields (maintainers, development_status).
…as selector

View inheritance fails because Odoo forbids @string in xpath selectors.
Target the unique field name auto_expand_accounts_style_id instead.
visible_rows yields KpiMatrixRow objects and result['body'] yields dicts.
The variable names assumed (row, row_data) but zip was called in
(visible_rows, result['body']) order, so row became the dict and the
.kpi attribute access raised AttributeError.
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.

1 participant