@@ -5,18 +5,37 @@ class SppStarter(models.TransientModel):
55 _name = "spp.starter"
66 _description = "SPP Starter"
77
8+ STATE_SELECTION = [
9+ ("0" , "Organization Setup" ),
10+ ("1" , "Registry Setup" ),
11+ ("2" , "Chosen Registry Setup" ),
12+ ]
13+ SP_MIS_STATE_SELECTION = [
14+ ("0" , "SP-MIS" ),
15+ ("1" , "Service Points" ),
16+ ("2" , "Cash Transfer" ),
17+ ("3" , "In-Kind Transfer" ),
18+ ]
19+ FARMER_STATE_SELECTION = [
20+ ("0" , "Farmer Registry" ),
21+ ]
22+
823 state = fields .Selection (
9- selection = [
10- ("0" , "Organization" ),
11- ("1" , "Registry" ),
12- ("2" , "Service Points" ),
13- ("3" , "Cash Transfer" ),
14- ("4" , "In-Kind Transfer" ),
15- ("5" , "Grievance Redress Mechanism" ),
16- ],
24+ selection = STATE_SELECTION ,
25+ required = True ,
26+ default = "0" ,
27+ )
28+ state_spmis = fields .Selection (
29+ selection = SP_MIS_STATE_SELECTION ,
1730 required = True ,
1831 default = "0" ,
1932 )
33+ state_farmer = fields .Selection (
34+ selection = FARMER_STATE_SELECTION ,
35+ required = True ,
36+ default = "0" ,
37+ )
38+ is_last_step = fields .Boolean (compute = "_compute_is_last_step" )
2039 # STEP 1
2140 org_name = fields .Char (
2241 readonly = True ,
@@ -37,16 +56,16 @@ class SppStarter(models.TransientModel):
3756 help = "To set the default currency for financial transactions." ,
3857 )
3958 # STEP 2
40- managing_target = fields .Selection (
59+ registry_target = fields .Selection (
4160 selection = [
42- ("individual" , "Individual" ),
43- ("group" , "Group" ),
44- ("both" , "Both" ),
61+ ("spmis" , "SP-MIS" ),
62+ ("farmer" , "Farmer Registry" ),
4563 ],
4664 readonly = True ,
47- default = "both " ,
65+ default = "spmis " ,
4866 help = "To customize data models and interfaces." ,
4967 )
68+
5069 location_assignment = fields .Selection (
5170 selection = [
5271 ("yes" , "Yes" ),
@@ -65,7 +84,18 @@ class SppStarter(models.TransientModel):
6584 default = "yes" ,
6685 help = "To determine if identity management modules should be installed." ,
6786 )
68- # STEP 3
87+ # STEP 3 SP-MIS
88+ sp_mis_demo_management = fields .Selection (
89+ selection = [
90+ ("yes" , "Yes" ),
91+ ("no" , "No" ),
92+ ],
93+ readonly = True ,
94+ default = "yes" ,
95+ help = "To gauge whether demo module for SP-MIS is needed." ,
96+ )
97+
98+ # STEP 4 SP-MIS
6999 service_point_management = fields .Selection (
70100 selection = [
71101 ("yes" , "Yes" ),
@@ -75,7 +105,7 @@ class SppStarter(models.TransientModel):
75105 default = "yes" ,
76106 help = "To gauge whether additional logistics modules are needed." ,
77107 )
78- # STEP 4
108+ # STEP 5 SP-MIS
79109 cash_transfer_needed = fields .Selection (
80110 selection = [
81111 ("yes" , "Yes" ),
@@ -94,7 +124,7 @@ class SppStarter(models.TransientModel):
94124 default = "yes" ,
95125 help = "To add functionality for storing financial information." ,
96126 )
97- # STEP 5
127+ # STEP 6 SP-MIS
98128 conducting_inkind_transfer = fields .Selection (
99129 selection = [
100130 ("yes" , "Yes" ),
@@ -104,17 +134,29 @@ class SppStarter(models.TransientModel):
104134 default = "yes" ,
105135 help = "To decide if modules for inventory management are needed." ,
106136 )
107- # STEP 6
108- complaint_management = fields .Selection (
137+
138+ # STEP 3 Farmer Registry
139+ farmer_demo_management = fields .Selection (
109140 selection = [
110141 ("yes" , "Yes" ),
111142 ("no" , "No" ),
112143 ],
113144 readonly = True ,
114- default = "yes " ,
115- help = "To add modules for complaint management if needed." ,
145+ default = "no " ,
146+ help = "To gauge whether demo module for farmer registry is needed." ,
116147 )
117148
149+ def _compute_is_last_step (self ):
150+ for rec in self :
151+ if rec .registry_target == "spmis" :
152+ rec .is_last_step = (
153+ rec .state == rec .STATE_SELECTION [- 1 ][0 ] and rec .state_spmis == rec .SP_MIS_STATE_SELECTION [- 1 ][0 ]
154+ )
155+ if rec .registry_target == "farmer" :
156+ rec .is_last_step = (
157+ rec .state == rec .STATE_SELECTION [- 1 ][0 ] and rec .state_farmer == rec .FARMER_STATE_SELECTION [- 1 ][0 ]
158+ )
159+
118160 def action_done (self ):
119161 self .ensure_one ()
120162 self ._adjust_main_company_details ()
@@ -127,15 +169,27 @@ def action_done(self):
127169 def action_last_state (self ):
128170 self .ensure_one ()
129171 state_int = int (self .state )
130- if state_int > 0 :
131- self .state = str (state_int - 1 )
172+ if state_int == len (self .STATE_SELECTION ) - 1 :
173+ if self .registry_target == "spmis" and int (self .state_spmis ) > 0 :
174+ self .state_spmis = str (int (self .state_spmis ) - 1 )
175+ elif self .registry_target == "farmer" and int (self .state_farmer ) > 0 :
176+ self .state_farmer = str (int (self .state_farmer ) - 1 )
177+ else :
178+ self .state = str (state_int - 1 )
179+ else :
180+ self .state = str (max (state_int - 1 , 0 ))
132181 return self ._reopen ()
133182
134183 def action_next_state (self ):
135184 self .ensure_one ()
136185 state_int = int (self .state )
137- if state_int < 5 :
186+ if state_int < len ( self . STATE_SELECTION ) - 1 :
138187 self .state = str (state_int + 1 )
188+ if state_int == len (self .STATE_SELECTION ) - 1 :
189+ if self .registry_target == "spmis" :
190+ self .state_spmis = str (int (self .state_spmis ) + 1 )
191+ if self .registry_target == "farmer" :
192+ self .state_farmer = str (int (self .state_farmer ) + 1 )
139193 return self ._reopen ()
140194
141195 def _adjust_main_company_details (self ):
@@ -156,24 +210,37 @@ def find_module(module_name):
156210 return self .env .ref (f"base.module_{ module_name } " , raise_if_not_found = False )
157211
158212 res = find_module ("theme_openspp_muk" )
159- if self .managing_target == "individual" :
160- res |= find_module ("g2p_registry_individual" )
161- if self .managing_target == "group" :
162- res |= find_module ("g2p_registry_group" )
163- if self .managing_target == "both" :
164- res |= find_module ("g2p_registry_membership" )
165- if self .location_assignment == "yes" :
166- res |= find_module ("spp_area" )
213+ if self .registry_target == "spmis" :
214+ res |= find_module ("spp_base" )
215+ res |= find_module ("spp_programs" )
216+ res |= find_module ("spp_change_request" )
217+ res |= find_module ("spp_change_request_change_info" )
218+ res |= find_module ("spp_event_data" )
219+ if self .sp_mis_demo_management == "yes" :
220+ res |= find_module ("spp_demo" )
221+ if self .location_assignment == "yes" :
222+ res |= find_module ("spp_area" )
223+ if self .service_point_management == "yes" :
224+ res |= find_module ("spp_service_points" )
225+ if self .cash_transfer_needed == "yes" :
226+ res |= find_module ("spp_entitlement_cash" )
227+ if self .bank_details_needed == "yes" :
228+ res |= find_module ("g2p_bank" )
229+ if self .conducting_inkind_transfer == "yes" :
230+ res |= find_module ("spp_entitlement_in_kind" )
231+
232+ if self .registry_target == "farmer" :
233+ # TODO: needs to change this once the module for farmer registry default UI is created
234+ res |= find_module ("spp_farmer_registry_base" )
235+ if self .location_assignment == "yes" :
236+ res |= find_module ("spp_area_gis" )
237+ if self .farmer_demo_management == "yes" :
238+ res |= find_module ("spp_farmer_registry_demo" )
239+ res |= find_module ("spp_programs" )
240+
167241 if self .id_management == "yes" :
168242 res |= find_module ("spp_idpass" )
169- if self .service_point_management == "yes" :
170- res |= find_module ("spp_service_points" )
171- if self .cash_transfer_needed == "yes" :
172- res |= find_module ("spp_entitlement_cash" )
173- if self .bank_details_needed == "yes" :
174- res |= find_module ("g2p_bank" )
175- if self .conducting_inkind_transfer == "yes" :
176- res |= find_module ("spp_entitlement_in_kind" )
243+
177244 return res
178245
179246 def _remove_default_products_if_needed (self ):
0 commit comments