Skip to content

Commit 0501c8e

Browse files
authored
Merge pull request #655 from OpenSPP/649-compliance-module-fix
add button to show all cycle members
2 parents d89b986 + 3507470 commit 0501c8e

File tree

3 files changed

+50
-1
lines changed

3 files changed

+50
-1
lines changed

spp_programs/views/cycle_view.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,13 @@ Part of OpenSPP. See LICENSE file for full copyright and licensing details.
2828
</xpath>
2929
<xpath expr="//button[@name='open_entitlements_form']" position="attributes">
3030
<attribute name="invisible">entitlements_count == 0</attribute>
31+
<attribute name="icon">fa-calculator</attribute>
3132
</xpath>
3233
<xpath expr="//button[@name='open_entitlements_form']" position="after">
3334
<button
3435
type="object"
3536
class="oe_stat_button"
36-
icon="fa-folder-open-o"
37+
icon="fa-calculator"
3738
name="open_entitlements_form"
3839
invisible="inkind_entitlements_count == 0"
3940
>
@@ -57,6 +58,10 @@ Part of OpenSPP. See LICENSE file for full copyright and licensing details.
5758
invisible="state != 'draft' or inkind_entitlements_count == 0"
5859
/>
5960
</xpath>
61+
62+
<xpath expr="//button[@name='open_payments_form']" position="attributes">
63+
<attribute name="icon">fa-file-text-o</attribute>
64+
</xpath>
6065
</field>
6166
</record>
6267

spp_programs_compliance_criteria/models/g2p_cycle.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ class G2pCycle(models.Model):
77
_inherit = "g2p.cycle"
88

99
allow_filter_compliance_criteria = fields.Boolean(compute="_compute_allow_filter_compliance_criteria")
10+
all_members_count = fields.Integer(string="# Enrollments", readonly=True, compute="_compute_all_members_count")
1011

1112
@api.depends("program_id", "program_id.compliance_managers")
1213
def _compute_allow_filter_compliance_criteria(self):
@@ -36,3 +37,31 @@ def _get_compliance_criteria_domain(self):
3637
membership = self.cycle_membership_ids if self.cycle_membership_ids else None
3738
domain.append(manager_ref._prepare_eligible_domain(membership))
3839
return OR(domain)
40+
41+
def _compute_all_members_count(self):
42+
for rec in self:
43+
domain = rec._get_beneficiaries_domain(None)
44+
members_count = self.env["g2p.cycle.membership"].search_count(domain)
45+
rec.update({"all_members_count": members_count})
46+
47+
def open_all_members_form(self):
48+
self.ensure_one()
49+
50+
action = {
51+
"name": _("Cycle Members"),
52+
"type": "ir.actions.act_window",
53+
"res_model": "g2p.cycle.membership",
54+
"context": {
55+
"create": False,
56+
"default_cycle_id": self.id,
57+
},
58+
"view_mode": "list,form",
59+
"domain": [("cycle_id", "=", self.id)],
60+
}
61+
return action
62+
63+
def open_members_form(self):
64+
self.ensure_one()
65+
action = super().open_members_form()
66+
action["name"] = _("Cycle Beneficiaries")
67+
return action

spp_programs_compliance_criteria/views/g2p_cycle_views.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,21 @@
1818
/>
1919
<field name="allow_filter_compliance_criteria" invisible="1" />
2020
</xpath>
21+
22+
<xpath expr="//button[@name='open_members_form']" position="before">
23+
<button
24+
type="object"
25+
class="oe_stat_button"
26+
title="Open all members form"
27+
icon="fa-list-alt"
28+
name="open_all_members_form"
29+
>
30+
<div class="o_form_field o_stat_info">
31+
<field name="all_members_count" class="o_stat_value" />
32+
<span class="o_stat_text">Enrollments</span>
33+
</div>
34+
</button>
35+
</xpath>
2136
</field>
2237
</record>
2338

0 commit comments

Comments
 (0)