Skip to content

feat(spp_mis_demo_v2): add child/spouse/other membership types#165

Merged
emjay0921 merged 3 commits into19.0from
feat/922-mis-demo-membership-types
Apr 30, 2026
Merged

feat(spp_mis_demo_v2): add child/spouse/other membership types#165
emjay0921 merged 3 commits into19.0from
feat/922-mis-demo-membership-types

Conversation

@emjay0921
Copy link
Copy Markdown
Contributor

Why is this change needed?

OpenProject #922 — spp_mis_demo_v2 should populate group-membership-type on every household membership so the demo data realistically exercises the vocabulary. Before this change, only head was assigned; spouse/adult/child members had no type at all, and a demo change-request referenced a non-existent xmlid (spp_registry.group_membership_kind_child).

How was the change implemented?

  • New demo vocabulary dataspp_mis_demo_v2/data/vocabulary_group_membership_type.xml registers child, spouse, other codes against the existing vocab_group_membership_type vocabulary. Scoped to the demo module (not spp_vocabulary) so core stays non-prescriptive about household composition.

  • Blueprint roles drive type assignment. The existing story blueprints and seeded blueprints already encode demographically-correct gender and age ranges (child ≤ 17 in most cases, adult spouse opposite-gender to head, etc.). The generator just maps role → membership type:

    Blueprint role Membership type
    head head
    spouse spouse
    child child
    adult, elderly other
  • seeded_volume_generator.py — replaced _get_head_type_id with a cached _get_membership_type_id(code); assigns per-role.

  • mis_demo_generator.py — applies the mapping in _create_household_members for spouse, adults, and children (head already had it); also fixed the stale xmlid on the carlos_elena_morales add_member demo change request.

New unit tests

  • test_non_head_members_have_membership_types — asserts every generated membership carries exactly one of {head, spouse, child, other}, at most one spouse per household, and child members are younger than the head.

Unit tests executed by the author

Full spp_mis_demo_v2 suite (270 tests, Docker): 0 failed on my changes. The only errors (3) are pre-existing test_claim169_demo FK issues on res_partner_bank, unrelated to this PR.

How to test manually

  1. Install/upgrade spp_mis_demo_v2 on a fresh DB.
  2. Open any demo household (Bautista, Navarro, Morales, etc.).
  3. On the Membership tab every member should show a type tag: one Head, optionally one Spouse, zero or more Child, with the rest as Other.
  4. Verify the "Add newborn to Morales household" demo CR (CR about Baby Morales) has a valid Relationship value instead of erroring on a missing xmlid.

Related links

Enable the child, spouse, and other group-membership-type vocabulary
codes inside the demo module and apply them when generating households.
The existing blueprint roles already honor gender and age ranges, so
the generator assigns membership types from those roles:

  head   -> head
  spouse -> spouse
  child  -> child
  adult, elderly -> other

Fix a stale reference to spp_registry.group_membership_kind_child in
the add_member change-request demo data; point it to the new xmlid.

The types are scoped to spp_mis_demo_v2 (not spp_vocabulary) so that
core stays non-prescriptive about household composition.
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 22, 2026

Codecov Report

❌ Patch coverage is 96.29630% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 71.60%. Comparing base (b061135) to head (230ae76).
⚠️ Report is 22 commits behind head on 19.0.

Files with missing lines Patch % Lines
spp_mis_demo_v2/models/seeded_volume_generator.py 93.33% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             19.0     #165      +/-   ##
==========================================
+ Coverage   71.45%   71.60%   +0.14%     
==========================================
  Files         932      933       +1     
  Lines       54792    55372     +580     
==========================================
+ Hits        39152    39649     +497     
- Misses      15640    15723      +83     
Flag Coverage Δ
spp_base_common 90.26% <ø> (ø)
spp_dci_demo 69.23% <ø> (ø)
spp_mis_demo_v2 73.61% <96.29%> (+3.59%) ⬆️
spp_programs 64.51% <ø> (+0.17%) ⬆️
spp_security 66.66% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
spp_mis_demo_v2/__manifest__.py 0.00% <ø> (ø)
spp_mis_demo_v2/models/mis_demo_generator.py 67.58% <100.00%> (+1.65%) ⬆️
spp_mis_demo_v2/models/seeded_volume_generator.py 94.28% <93.33%> (-1.06%) ⬇️

... and 7 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces structured membership types (head, spouse, child, and other) for household members within the demo data generator. Key changes include the definition of new vocabulary codes, updates to the mis_demo_generator and seeded_volume_generator to assign these types based on member roles, and the addition of a test case to verify correct assignment and basic business logic. One improvement was suggested to use the modern Odoo Command helper instead of legacy tuple syntax for Many2many field operations in the seeded volume generator.


type_id = self._get_membership_type_id(type_code)
if type_id:
mval["membership_type_ids"] = [(4, type_id)]
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Using the Command helper is preferred over the legacy tuple syntax (4, id) for Many2many fields in modern Odoo versions.

Suggested change
mval["membership_type_ids"] = [(4, type_id)]
mval["membership_type_ids"] = [Command.link(type_id)]

@gonzalesedwin1123
Copy link
Copy Markdown
Member

@emjay0921 Please fix the CI / test errors

… run

`_get_demographic_enricher` cached the enricher on the model class
(`type(self)._demo_enricher_cache`), which survives TransactionCase
savepoint rollbacks between test cases. The enricher's `_bank_ids` /
vocab / country caches are populated against a specific cursor at
construction time; once that cursor's banks roll back at the end of a
test, a later test re-using the cached enricher picks one of those
now-non-existent ids and the next `res.partner.bank` insert raises a
`res_partner_bank_bank_id_fkey` violation. Past that point Postgres
aborts the transaction and the rest of the demo generation falls over,
which is exactly what `test_claim169_credential_generation` was hitting
in CI.

The `_ensure_banks` / `_cache_vocab_ids` lookups inside the enricher
are idempotent (search-then-create), so re-instantiating per call costs
only a handful of SELECTs and avoids the stale-cache class entirely.
Local `spp_mis_demo_v2` suite is now green: 0 failed, 0 errors of 270.
The new `data/vocabulary_group_membership_type.xml` data file
registers `child` / `spouse` / `other` membership-type codes. Without
a version bump, `Apps → Upgrade` won't re-run data files on existing
databases, so these codes wouldn't appear after upgrade — only on
fresh installs.
@emjay0921 emjay0921 merged commit 6e859bb into 19.0 Apr 30, 2026
20 checks passed
@emjay0921 emjay0921 deleted the feat/922-mis-demo-membership-types branch April 30, 2026 02:35
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.

2 participants