File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -19,3 +19,33 @@ def _compute_inkind_entitlements_count(self):
19
19
for rec in self :
20
20
entitlements_count = self .env ["g2p.entitlement.inkind" ].search_count ([("cycle_id" , "=" , rec .id )])
21
21
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 )
You can’t perform that action at this time.
0 commit comments