Se implementa wizard para crear llamadas a prospectos (en las pruebas), #39

This commit is contained in:
Camilo Gonzalez 2023-08-21 11:59:38 -05:00
parent fd667a518b
commit d330ac341a
6 changed files with 93 additions and 33 deletions

View File

@ -20,10 +20,12 @@ def register():
prospect_trace.ProspectTrace,
prospect.AssignOperatorStart,
prospect_trace.ScheduleCallStart,
prospect_trace.MakeCallStart,
module='sale_opportunity_management', type_='model')
Pool.register(
prospect_trace.ScheduleCall,
prospect.AssignOperator,
prospect_trace.MakeCall,
module='sale_opportunity_management', type_='wizard')
Pool.register(
module='sale_opportunity_management', type_='report')

View File

@ -30,11 +30,3 @@ class Call(ModelSQL, ModelView):
@classmethod
def default_date(cls):
return date.today()
@fields.depends('interest', 'call_result')
def on_change_interest(self):
if self.interest:
if self.interest == '0':
self.call_result = 'missed_call'
else:
self.call_result = 'answered_call'

View File

@ -56,26 +56,6 @@ class ProspectTrace(DeactivableMixin, ModelSQL, ModelView):
def wizard_schedule(cls, prospect_traces):
pass
@fields.depends('calls', 'pending_call', 'current_interest', 'state')
def on_change_calls(self):
if not self.calls:
return
last_call = self.calls[-1]
self.current_interest = last_call.interest
already_exist_a_call = len(self.calls) > 1
if already_exist_a_call:
followup_call_type = CallTypes.get_call_types()[1][0]
last_call.call_type = followup_call_type
else:
first_call_type = CallTypes.get_call_types()[0][0]
last_call.call_type = first_call_type
if self.pending_call:
self.pending_call = None
self.state = 'open'
@fields.depends('prospect', 'prospect_city', 'prospect_contact')
def on_change_prospect(self):
if not self.prospect:
@ -142,3 +122,57 @@ class ScheduleCall(Wizard):
prospect_trace.save()
return 'end'
class MakeCallStart(ModelView):
'Inicio de creación de llamada a seguimiento de prospecto'
__name__ = 'sale.prospect_trace.make_call.start'
description = fields.Text('Description')
interest = fields.Selection(
Interest.get_interest_levels(), 'Interest', required=True)
class MakeCall(Wizard):
'Crear llamada a un seguimiento de prospecto'
__name__ = 'sale.prospect_trace.make_call'
start = StateView(
'sale.prospect_trace.make_call.start',
'sale_opportunity_management.make_call_start_view_form', [
Button("Cancel", 'end', 'tryton-cancel'),
Button("Make call", 'make_call', 'tryton-ok', default=True)])
make_call = StateTransition()
def transition_make_call(self):
prospect_trace = self.record
pool = Pool()
Call = pool.get('sale.call')
call = Call()
call.description = self.start.description
call.interest = self.start.interest
call.prospect_trace = self.record
if call.interest == '0':
call.call_result = 'missed_call'
else:
call.call_result = 'answered_call'
already_exist_a_call = len(prospect_trace.calls) >= 1
if already_exist_a_call:
followup_call_type = CallTypes.get_call_types()[1][0]
call.call_type = followup_call_type
else:
first_call_type = CallTypes.get_call_types()[0][0]
call.call_type = first_call_type
call.save()
prospect_trace.current_interest = call.interest
if prospect_trace.pending_call:
prospect_trace.pending_call = None
prospect_trace.state = 'open'
prospect_trace.calls += (call,)
prospect_trace.save()
return 'end'

View File

@ -68,5 +68,16 @@ this repository contains the full copyright notices and license terms. -->
<field name="string">Schedule call</field>
<field name="model" search="[('model', '=', 'sale.prospect_trace')]"/>
</record>
<record model="ir.action.wizard" id="make_call_wizard">
<field name="name">Make call</field>
<field name="wiz_name">sale.prospect_trace.make_call</field>
</record>
<record model="ir.ui.view" id="make_call_start_view_form">
<field name="model">sale.prospect_trace.make_call.start</field>
<field name="type">form</field>
<field name="name">make_call_start_form</field>
</record>
</data>
</tryton>

View File

@ -185,10 +185,22 @@ Crear seguimiento de prospecto::
'Gerente R.H'
Crear llamadas a un seguimiento de prospecto desde el seguimiento de prospecto::
>>> call1 = prospect_trace.calls.new(description='First call', interest='0')
>>> call2 = prospect_trace.calls.new(description='Second call', interest='1')
>>> call3 = prospect_trace.calls.new(description='Third call', interest='3')
>>> prospect_trace.save()
>>> make_call = Wizard('sale.prospect_trace.make_call', [prospect_trace])
>>> make_call.form.description = 'First call to the prospect'
>>> make_call.form.interest = '0'
>>> make_call.execute('make_call')
>>> make_call = Wizard('sale.prospect_trace.make_call', [prospect_trace])
>>> make_call.form.description = 'Second call to the prospect'
>>> make_call.form.interest = '1'
>>> make_call.execute('make_call')
>>> make_call = Wizard('sale.prospect_trace.make_call', [prospect_trace])
>>> make_call.form.description = 'Third call to the prospect'
>>> make_call.form.interest = '3'
>>> make_call.execute('make_call')
.. >>> prospect_trace.save()
Verificar estado final del seguimiento del prospecto y sus llamadas
>>> prospect_trace.calls[0].call_result
@ -223,7 +235,10 @@ Programar una próxima llamada pendiente al seguimiento de prospecto::
'with_pending_calls'
Crear una llamada agendada previamente:
>>> call4 = prospect_trace.calls.new(description='fourth call', interest='3')
>>> make_call = Wizard('sale.prospect_trace.make_call', [prospect_trace])
>>> make_call.form.description = 'Fourth call to the prospect'
>>> make_call.form.interest = '3'
>>> make_call.execute('make_call')
>>> prospect_trace.pending_call

View File

@ -0,0 +1,6 @@
<?xml version="1.0"?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<form>
</form>