Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions spp_farmer_registry_demo/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,16 @@ Dependencies
Changelog
=========

19.0.2.1.2
~~~~~~~~~~

- fix(demo): put the Input Subsidy Program on **manual** entitlement
approval (``auto_approve_entitlements=False``) so a demo user can walk
the full cycle → entitlement approval chain, not just cycle approval.
The flag is now per-program (every other demo program stays
auto-approve), and historically seeded cycles are unaffected because
the generator force-approves their pending entitlements (#1122)

19.0.2.1.1
~~~~~~~~~~

Expand Down
2 changes: 1 addition & 1 deletion spp_farmer_registry_demo/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "OpenSPP Farmer Registry Demo",
"summary": "Demo generator for Farmer Registry with fixed stories and volume generation",
"category": "OpenSPP",
"version": "19.0.2.1.1",
"version": "19.0.2.1.2",
"sequence": 1,
"author": "OpenSPP.org",
"website": "https://github.com/OpenSPP/OpenSPP2",
Expand Down
5 changes: 5 additions & 0 deletions spp_farmer_registry_demo/models/demo_programs.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
"Eligibility: Farms ≤5 hectares with productive land. "
"Benefit: Base amount plus per-hectare top-up.",
"target_type": "group",
# OP#1122: keep this program on MANUAL entitlement approval (cycles
# still go through their own approval stage) so the demo can show the
# full cycle -> entitlement approval chain, not just cycle approval.
# Every other demo program stays auto-approve.
"auto_approve_entitlements": False,
"entitlement_amount": 200.0,
"entitlement_formula": "input_subsidy_base + (farm_size_hectares * per_hectare_subsidy)",
# Benefit lines: ₱100 base + ₱50 per hectare. Example: a 2 ha farm gets
Expand Down
5 changes: 4 additions & 1 deletion spp_farmer_registry_demo/models/farmer_demo_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -1699,7 +1699,10 @@ def _create_program_via_wizard(self, program_def):
"rrule_type": program_def.get("rrule_type", "monthly"),
"month_by": "date",
"day": 1,
"auto_approve_entitlements": True,
# Auto-approve entitlements by default, but let a program opt out
# (OP#1122) so a demo user can walk the entitlement-approval stage
# of a cycle, not just the cycle-approval stage.
"auto_approve_entitlements": program_def.get("auto_approve_entitlements", True),
}

# Enable compliance verification at wizard time for programs that ship a
Expand Down
4 changes: 4 additions & 0 deletions spp_farmer_registry_demo/readme/HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### 19.0.2.1.2

- fix(demo): put the Input Subsidy Program on **manual** entitlement approval (`auto_approve_entitlements=False`) so a demo user can walk the full cycle → entitlement approval chain, not just cycle approval. The flag is now per-program (every other demo program stays auto-approve), and historically seeded cycles are unaffected because the generator force-approves their pending entitlements (#1122)

### 19.0.2.1.1

- fix(demo): name each farm after its head member and give every member the head's family name so a household reads as one family; farm names and registry IDs stay unique and generation remains seed-deterministic, resolving duplicate farm names and duplicate Tax/National IDs (#1114)
Expand Down
15 changes: 13 additions & 2 deletions spp_farmer_registry_demo/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,17 @@ <h2><a class="toc-backref" href="#toc-entry-1">Changelog</a></h2>
</div>
</div>
<div class="section" id="section-1">
<h1>19.0.2.1.2</h1>
<ul class="simple">
<li>fix(demo): put the Input Subsidy Program on <strong>manual</strong> entitlement
approval (<tt class="docutils literal">auto_approve_entitlements=False</tt>) so a demo user can walk
the full cycle → entitlement approval chain, not just cycle approval.
The flag is now per-program (every other demo program stays
auto-approve), and historically seeded cycles are unaffected because
the generator force-approves their pending entitlements (#1122)</li>
</ul>
</div>
<div class="section" id="section-2">
<h1>19.0.2.1.1</h1>
<ul class="simple">
<li>fix(demo): name each farm after its head member and give every member
Expand All @@ -502,7 +513,7 @@ <h1>19.0.2.1.1</h1>
(#1114)</li>
</ul>
</div>
<div class="section" id="section-2">
<div class="section" id="section-3">
<h1>19.0.2.1.0</h1>
<ul class="simple">
<li>feat(demo): add GIS + irrigation scenario (FM4) with reservoir + canal
Expand All @@ -521,7 +532,7 @@ <h1>19.0.2.1.0</h1>
tables and the CR overview</li>
</ul>
</div>
<div class="section" id="section-3">
<div class="section" id="section-4">
<h1>19.0.2.0.0</h1>
<ul class="simple">
<li>Initial migration to OpenSPP2</li>
Expand Down
41 changes: 41 additions & 0 deletions spp_farmer_registry_demo/tests/test_demo_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,19 @@ def test_get_all_demo_programs(self):
self.assertIn("id", prog)
self.assertIn("name", prog)

def test_at_least_one_program_uses_manual_entitlement_approval(self):
"""OP#1122: at least one demo program must opt out of auto-approve so
the cycle -> entitlement approval chain is demonstrable end-to-end."""
from odoo.addons.spp_farmer_registry_demo.models.demo_programs import (
get_all_demo_programs,
)

manual = [p for p in get_all_demo_programs() if p.get("auto_approve_entitlements") is False]
self.assertTrue(
manual,
"At least one demo program must set auto_approve_entitlements=False (OP#1122)",
)

def test_get_demo_program_by_id_found(self):
"""get_demo_program_by_id should find existing program."""
from odoo.addons.spp_farmer_registry_demo.models.demo_programs import (
Expand Down Expand Up @@ -658,6 +671,34 @@ def test_flat_program_keeps_single_line(self):
self.assertEqual(len(items), 1, "Equipment Grant is a flat grant — one line")
self.assertFalse(items.multiplier_field, "Flat grant line has no multiplier")

def test_input_subsidy_requires_manual_entitlement_approval(self):
"""OP#1122: Input Subsidy opts out of auto-approve so the demo can show
the entitlement-approval stage of a cycle, not just cycle approval.

The wizard flag propagates to the default cycle manager, which is what
new cycles inherit their auto_approve_entitlements behaviour from.
"""
wizard = self.Generator.create({"name": _unique("Manual Approve Test")})
program = wizard._create_program_via_wizard(self._program_def("input_subsidy"))

cycle_manager = program.get_manager(program.MANAGER_CYCLE)
self.assertFalse(
cycle_manager.auto_approve_entitlements,
"Input Subsidy must NOT auto-approve entitlements (OP#1122)",
)

def test_other_programs_keep_auto_approve_entitlements(self):
"""Programs that do not opt out keep auto-approve, so their demo cycles
still flow straight through without a manual entitlement step."""
wizard = self.Generator.create({"name": _unique("Auto Approve Test")})
program = wizard._create_program_via_wizard(self._program_def("livestock_support"))

cycle_manager = program.get_manager(program.MANAGER_CYCLE)
self.assertTrue(
cycle_manager.auto_approve_entitlements,
"Programs without an opt-out must keep auto-approve entitlements",
)

def test_program_manager_demo_user_can_approve_and_enqueue(self):
"""The Program Manager demo user holds the groups needed to approve a
cycle (program manager) and enqueue the entitlement-validation job
Expand Down
Loading