Skip to content

[18.0][IMP] crm_compassion, sponsorship_compassion: fundraising detail in UTM instead of analytic accounts - #2219

Open
davidwul wants to merge 12 commits into
18.0from
18.0-utm-from-origin-v2
Open

davidwul wants to merge 12 commits into
18.0from
18.0-utm-from-origin-v2

Conversation

@davidwul

@davidwul davidwul commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Why

In v14 every event, ambassador, partner origin... had its own analytic account, so the analytic plans grew to thousands of accounts and mixed two questions: where does the money come from and how is it allocated. After the v18 migration we keep the analytic plans for allocation and funds only, and the fundraising detail moves to the standard UTM fields (campaign / source / medium) of the sponsorships and invoices. The reporting reads the UTM of each journal item through its contract (else through its invoice).

UTM model:

  • a campaign groups several occasions; each occasion (event, mailing, publication...) is a source;
  • an event is a source, its campaign is optional;
  • a peer-to-peer fundraising event (crowdfunding, sport) is a campaign, each fundraiser a source (fundraisers: see the companion PR in compassion-website);
  • every source has a category (event, fundraiser, ambassador, existing sponsor, media, advertising, mailing, web, transfer, other, unknown): the high-level fundraising axis of the reports;
  • a sponsorship always has a source (Unknown rather than empty) and a medium.

Changes

sponsorship_compassion / crm_compassion

  • recurring.contract.origin gets a campaign and a source, given to its sponsorships that have none (on creation, on change of origin, on change of the origin's UTM). A sponsorship with its own UTM keeps it.
  • Each event gets a source named after it (a campaign for a peer-to-peer event, _ensure_campaign), given to its origins. A copied event gets its own.
  • An event created from an opportunity takes the opportunity's campaign: an action of several events (e.g. a speaker tour) is one campaign, each event its own source.
  • utm.source.category; sources of events and communications get theirs.
  • Medium guessed from the source (by name, then by category), else Other.
  • Event of a journal item: origin of its sponsorship, then source / campaign of its invoice, then its analytic accounts (history).
  • Fewer analytic accounts:
    • a new event gets an account only for the types in crm_compassion.analytic_event_types, in the plan crm_compassion.analytic_event_plan_id (system parameters; default: every event, plan Events, i.e. unchanged behaviour);
    • no analytic account per portal user nor per partner origin anymore.
  • Expenses of a campaign / source / event: analytic account created on demand (button Track expenses), in the plan sponsorship_compassion.cost_analytic_plan_id, pointing to its campaign / source, so a report can put funds raised next to expenses.
  • Works with T3491 / T3511 (event in any analytic plan): the account of a migrated event moves to the plan configured for its type (default Events).

sponsorship_sub_management

  • A sub sponsorship keeps the source, campaign and medium of its parent (the source Sub sponsorship hid the original fundraising in the reports).

Migration

  • crm_compassion 18.0.1.1.0 post-migration: the origins of an event take its campaign (when they have none), then their sponsorships without campaign take it. Sources are set by the clean-up script below.
  • Version bumps: crm_compassion 18.0.1.1.0, sponsorship_compassion 18.0.1.1.0, sponsorship_sub_management 18.0.1.0.1.
  • The Swiss settings and the data clean-up (sources / campaigns of the existing origins, categories, archiving of the analytic accounts) are done by a one-shot script in CompassionCH/tools (PR Child exit details #26), not by this module.

Impact on other offices (Nordic)

Tested on a copy of a recent Nordic database (odoo-nordic.conf): upgrade OK, no data changed by the upgrade.

  • crm_compassion is not installed at Nordic: the event, analytic plan and portal changes don't apply.
  • New sponsorships get the source Unknown when they have none (Nordic sets a source on few contracts). The campaign and medium they are created with are kept; no medium is forced when the source gives none.
  • Changing the origin of a sponsorship keeps its campaign (Nordic origins have no campaign).
  • New communication configs get the source category mailing.
  • Existing contracts, origins and sources are not modified.

Tests

  • New: crm_compassion/tests/test_event_campaign.py, sponsorship_compassion/tests/test_origin_campaign.py; test_event_analytic.py (T3491/T3511) adapted to start from the default settings.
  • Run on a copy of the migrated Swiss production database and on a copy of a Nordic database: upgrade OK, the new tests and the T3491/T3511 tests pass. The remaining errors on that copy are unrelated (tests needing demo data base.res_partner_address_*, and randint given a float in test_project_compassion).
  • Merges into the current 18.0 without conflict.

Companion PR: CompassionCH/compassion-website 18.0-utm-from-origin-v2 (fundraisers as sources, crowdfunding campaigns), which depends on this one.

🤖 Generated with Claude Code

…ships from their origin

The fundraising detail of a sponsorship moves from the analytic account of
its origin to its UTM campaign, which reporting reads through the contract
of each journal item.

- recurring.contract.origin gets a campaign, given to its sponsorships that
  have none (on creation, on change of origin, on change of the campaign of
  the origin); a sponsorship with its own campaign keeps it
- each event gets a campaign named after it when it has none, given to its
  origins; a copied event gets its own campaign
- migration: the origins of an event take its campaign, then their
  sponsorships without campaign

Assisted-by: claude-opus-5-5, high, claude-code
A campaign groups several occasions (events, mailings, publications), each
of them a source. An event is therefore a source, named after it, and its
campaign is optional. A peer-to-peer fundraising event (crowdfunding,
sport) is a campaign instead, each fundraiser being a source.

The origin also gets a source, given to its sponsorships that have none,
like its campaign.

Assisted-by: claude-opus-5-5, medium, claude-code
…paign

Lets other modules turn an event into a peer-to-peer one after its creation.

Assisted-by: claude-opus-5-5, medium, claude-code
…and campaign of its parent

It comes from the same fundraising; the source and campaign "Sub sponsorship"
hid it in the reporting.

Assisted-by: claude-opus-5-5, medium, claude-code
- utm.source gets a category (event, fundraiser, ambassador, existing sponsor,
  media, advertising, mailing, web, transfer, other, unknown): the high level
  fundraising axis of the reports
- a sponsorship always has a source: Unknown when neither it nor its origin
  has one; an Unknown source follows the origin like an empty one
- the sources of the events and of the communications get their category
- a sub sponsorship also keeps the medium of its parent

Assisted-by: claude-opus-5-5, medium, claude-code
A sponsorship created without medium gets the one of its source (by name,
then by category: event -> Event, fundraiser and web -> Website, ambassador ->
Personal contact, media and advertising -> Print), else Other.

Assisted-by: claude-opus-5-5, medium, claude-code
… from the UTM, fewer analytic accounts

- the event of a journal item comes from the origin of its sponsorship, then
  from the source or campaign of its invoice, then from its analytic accounts
  (history)
- the analytic account of a new event goes to a configurable plan, only for
  configurable types (system parameters crm_compassion.analytic_event_plan_id
  and crm_compassion.analytic_event_types; default: every event in Events)
- no analytic account per portal user nor per partner origin anymore: the
  ambassador is the source of the sponsorships

Assisted-by: claude-opus-5-5, medium, claude-code
…mpaigns, sources and events

The income of a campaign, a source or an event is followed by the UTM; its
expenses by an analytic account created on demand (button Track expenses), in
the plan of the system parameter sponsorship_compassion.cost_analytic_plan_id.
The account points to its campaign and / or source, so a report can put the
funds raised next to the expenses.

Assisted-by: claude-opus-5-5, medium, claude-code
…sts with the default settings

The account of an event migrated in another plan moves to the plan given
by the settings for its type (crm_compassion.analytic_event_plan_id, default
Events), not only to Events. The tests of the event analytic plan start
from the default settings, so they pass on a database with other ones.

Assisted-by: claude-opus-5-5, medium, claude-code
@greptile-apps

greptile-apps Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[High impact] The PR appears safe to merge; no new blocking issues were found.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
    Opportunity[Opportunity campaign] --> Event[Event]
    Event --> Origin[Origin campaign and source]
    Origin --> Contract[Sponsorship tracking]
    Contract --> Journal[Journal item event]
    Invoice[Invoice tracking] --> Journal
    Journal --> Income[Paid donation income]
    Event --> Account[Optional analytic account]
    Account --> Expenses[Event expenses]
Loading

Reviews (4) · Last reviewed commit: "[FIX] crm_compassion: event income searc..." · Reviewed by Greptile

…bution

- A new sponsorship takes the UTM defaults (context, website cookies of
  utm.mixin) before the ones of its origin and the Unknown source.
- On the form, changing the origin replaces the campaign / source of the
  origin selected before, and keeps the ones chosen apart.
- The event of a journal item is computed again when the source or campaign
  of its invoice changes.
- Editing an event no longer fails when Odoo refuses to move its analytic
  account to the plan of its type (a line already holds another account of
  that plan): the account stays in its plan, as in the migration.
- Changing the type of an event sets up its UTM (campaign of a peer-to-peer
  event, source of another one) and gives it to its origins.

Assisted-by: claude-opus-5-5, medium, claude-code
…paign

An action of several events (e.g. a speaker tour) is one campaign; each
event created from its opportunities gets that campaign, and its own source.

Assisted-by: claude-opus-5-5, medium, claude-code
The invoice lines of a sponsorship now get the event of its origin, so each
invoice of the monthly invoicing recomputed the income of its event by
loading all the event's invoice lines (thousands for some events): +15% on
the invoicing time on a copy of the production database. The income lines
and total are now searched / summed in the database (same rule: paid
customer invoice lines without sponsorship), and the income lines depend on
the invoice lines, so they follow their payment.

Assisted-by: claude-opus-5-5, medium, claude-code
@davidwul
davidwul requested a review from NoeBerdoz November 23, 2026 10:46
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