Skip to content

[17.0][ADD] mis_builder_analytic_source - #846

Closed
mileo wants to merge 1 commit into
OCA:17.0from
kmee:17.0-add-mis_builder_analytic_source
Closed

mileo wants to merge 1 commit into
OCA:17.0from
kmee:17.0-add-mis_builder_analytic_source

Conversation

@mileo

@mileo mileo commented Oct 13, 2026

Copy link
Copy Markdown
Member

Forward port of #845 (16.0).

Summary

Since 16.0 a journal item has an analytic_distribution instead of one analytic account. The analytic filter of a MIS report (analytic_distribution_search in [id]) keeps the full balance of every item whose distribution contains the account, so a P&L per project or contract is overstated as soon as an item is split. Costs that only exist as analytic lines (timesheets) are not seen. See #608.

This module adds mis.analytic.move.line, a SQL view over account.analytic.line with the fields MIS Builder expects from a move lines source. Analytic lines already carry the prorated amount, so a report that uses it as Move lines source gives the exact figures.

journal item: expense 1000, analytic_distribution {A: 60, B: 40, D: 100}  (A, B: projects; D: department plan)

balp[expense], analytic filter
  move lines source = account.move.line        A -> 1000
  move lines source = mis.analytic.move.line   A ->  600   B -> 400   D -> 1000

Differences from 16.0, because since 17.0 each root analytic plan is a column of account.analytic.line:

analytic_distribution   {"<account of each plan>,...": 100}, one key per line,
                        so the filter works for the accounts of every plan and a
                        line is never counted twice
view rebuilt            when an analytic plan is created, moved or deleted
                        (the plan column is added or dropped with CASCADE)

No change in mis_builder: it only uses the existing Move lines source option.

Evidence

mis_builder_analytic_source: 5 tests passing with the OCA CI image of 17.0 (local run, oca-ci/py3.10-odoo17.0):

  • the analytic lines of the move are in the view, with debit/credit and state;
  • same AEP expression and same analytic filter: 1000 on account.move.line, 600 / 400 per project and 1000 for the department (second plan) on the new source;
  • a new root plan rebuilds the view and its lines are found by the filter;
  • a manual analytic line without financial account lands on the fallback account;
  • multi-company record rule.

pre-commit passes.

Merge Danger

Door: two-way

New module, Alpha. Nothing changes for reports that keep account.move.line as source.

Blast Radius: opt-in

Only MIS report templates that select this source. Known limits in ROADMAP: no currency conversion (analytic lines are in company currency) and draft entries have no analytic lines.

@OCA-git-bot OCA-git-bot added series:17.0 mod:mis_builder_analytic_source Module mis_builder_analytic_source labels Oct 13, 2026
@mileo

mileo commented Oct 15, 2026

Copy link
Copy Markdown
Member Author

Moved to OCA/mis-builder-contrib#75, as requested. Thanks @sbidoul.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:mis_builder_analytic_source Module mis_builder_analytic_source series:17.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants