chore: Se crea reduce código duplicado creando campo _states_selection

This commit is contained in:
Camilo Gonzalez 2023-08-12 12:54:43 -05:00
parent 7e19fbdaec
commit 428767ab81

View File

@ -24,8 +24,8 @@ class ProspectTrace(ModelSQL, ModelView):
current_interest = fields.Selection(
Interest.get_interest_levels(), 'Current interest')
state = fields.Selection(
ProspectTraceStates.get_prospect_trace_states(), 'State')
_states_selection = ProspectTraceStates.get_prospect_trace_states()
state = fields.Selection(_states_selection, 'State')
@fields.depends('calls', 'current_interest')
def on_change_calls(self):
@ -40,10 +40,9 @@ class ProspectTrace(ModelSQL, ModelView):
@fields.depends('pending_calls', 'state')
def on_change_pending_calls(self):
pc_states = ProspectTraceStates.get_prospect_trace_states()
if self.pending_calls:
with_pending_calls = pc_states[2][0]
self.state = with_pending_calls
with_pending_calls_state = self._states_selection[2][0]
self.state = with_pending_calls_state
@fields.depends('prospect')
def on_change_prospect(self):
@ -56,9 +55,8 @@ class ProspectTrace(ModelSQL, ModelView):
if mobile_contact:
self.prospect_contact = mobile_contact
pc_states = ProspectTraceStates.get_prospect_trace_states()
open = pc_states[1][0]
self.state = open
open_state = self._states_selection[1][0]
self.state = open_state
def get_rec_name(self, name):
if self.prospect: