chore: Se crea reduce código duplicado creando campo _states_selection
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

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