Skip to content

Commit 27644c2

Browse files
Fix issue with In-kind Entitlement when clicking 'To Approve' button
1 parent 2fb7ccf commit 27644c2

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

spp_programs/models/cycle.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,33 @@ def _compute_inkind_entitlements_count(self):
1919
for rec in self:
2020
entitlements_count = self.env["g2p.entitlement.inkind"].search_count([("cycle_id", "=", rec.id)])
2121
rec.update({"inkind_entitlements_count": entitlements_count})
22+
23+
def get_entitlements(
24+
self,
25+
state,
26+
entitlement_model="g2p.entitlement",
27+
offset=0,
28+
limit=None,
29+
order=None,
30+
count=False,
31+
):
32+
"""
33+
Query entitlements based on state.
34+
Overrides OpenG2P's get_entitlements method to fix the issue with search_count offset parameter.
35+
:param state: List of states
36+
:param entitlement_model: String value of entitlement model to search
37+
:param offset: Optional integer value for the ORM search offset
38+
:param limit: Optional integer value for the ORM search limit
39+
:param order: Optional string value for the ORM search order fields
40+
:param count: Optional boolean for executing a search-count (if true) or search (if false: default)
41+
:return:
42+
"""
43+
domain = [("cycle_id", "=", self.id)]
44+
if state:
45+
if isinstance(state, str):
46+
state = [state]
47+
domain += [("state", "in", state)]
48+
49+
if count:
50+
return self.env["g2p.cycle.membership"].search_count(domain, limit=limit)
51+
return self.env[entitlement_model].search(domain, offset=offset, limit=limit, order=order)

0 commit comments

Comments
 (0)