feat: Se implementa agendación de tarea en las pruebas, #71

This commit is contained in:
Camilo Gonzalez 2023-09-18 19:49:58 -05:00
parent 78fcd0231d
commit 214c6fc089
6 changed files with 84 additions and 0 deletions

View File

@ -14,6 +14,7 @@ def register():
Pool.register(
user.User,
pending_call.PendingCall,
pending_call.PendingTask,
call.Call,
department.Department,
city.City,
@ -24,6 +25,7 @@ def register():
prospect_trace.ScheduleCallStart,
prospect_trace.MakeCallStart,
prospect_trace.MakeCallAsk,
prospect_trace.MakeCallAskTask,
prospect.ReassignProspectByOperatorStart,
prospect.ReassignProspectByProspectStart,
module='sale_opportunity_management', type_='model')

View File

@ -12,3 +12,18 @@ class PendingCall(ModelSQL, ModelView):
def get_rec_name(self, name):
if self.date:
return str(self.date)
class PendingTask(ModelSQL, ModelView):
'Tarea pendiente a un seguimiento de prospecto'
__name__ = "sale.pending_task"
description = fields.Text('Description', required=True)
done = fields.Boolean('Done')
prospect_trace = fields.Many2One(
'sale.prospect_trace', 'Prospect trace',
required=True, readonly=True)
@classmethod
def default_done(cls):
return False

View File

@ -147,6 +147,10 @@ class MakeCallStart(ModelView):
[('yes', 'Yes'),
('no', 'No')], 'Schedule call?', required=True)
schedule_task = fields.Selection(
[('yes', 'Yes'),
('no', 'No')], 'Schedule call?', required=True)
class MakeCallAsk(ModelView):
'Posible agendación de llamada luego de hacer llamada actual'
@ -163,6 +167,13 @@ class MakeCallAsk(ModelView):
return date
class MakeCallAskTask(ModelView):
'Posible agendación de tarea luego de hacer llamada actual'
__name__ = 'sale.prospect_trace.make_call.ask_task'
task_description = fields.Text('Description')
class MakeCall(Wizard):
'Crear llamada a un seguimiento de prospecto'
__name__ = 'sale.prospect_trace.make_call'
@ -182,6 +193,15 @@ class MakeCall(Wizard):
"Schedule call", 'schedule_call', 'tryton-ok', default=True)])
schedule_call = StateTransition()
ask_task = StateView(
'sale.prospect_trace.make_call.ask_task',
'sale_opportunity_management.make_call_ask_task_view_form', [
Button("Cancel", 'end', 'tryton-cancel'),
Button("Schedule task", 'schedule_task', 'tryton-ok', default=True)
]
)
schedule_task = StateTransition()
def transition_make_call(self):
prospect_trace = self.record
@ -216,12 +236,30 @@ class MakeCall(Wizard):
if self.start.schedule_call == 'yes':
return 'ask'
if self.start.schedule_task == 'yes':
return 'ask_task'
return 'end'
def transition_schedule_task(self):
self.create_schedule_task(self.ask_task.task_description, self.record)
return 'end'
def transition_schedule_call(self):
self.create_schedule_call(self.ask.datetime, self.record)
if (self.start.schedule_call and self.start.schedule_task) == 'yes':
return 'ask_task'
return 'end'
@classmethod
def create_schedule_task(cls, description, prospect_trace):
pool = Pool()
Task = pool.get('sale.pending_task')
task = Task()
task.description = description
task.prospect_trace = prospect_trace
task.save()
@classmethod
def create_schedule_call(cls, datetime, prospect_trace):
pool = Pool()

View File

@ -132,6 +132,11 @@ this repository contains the full copyright notices and license terms. -->
<field name="type">form</field>
<field name="name">make_call_ask_form</field>
</record>
<record model="ir.ui.view" id="make_call_ask_task_view_form">
<field name="model">sale.prospect_trace.make_call.ask_task</field>
<field name="type">form</field>
<field name="name">make_call_ask_task_form</field>
</record>
<record model="ir.model.button" id="make_call_wizard_button">
<field name="name">wizard_make_call</field>
<field name="string">Make call</field>

View File

@ -265,6 +265,23 @@ Crear una llamada agendada previamente::
>>> prospect_trace.state
'open'
Hacer llamada y programar tarea
>>> make_call = Wizard('sale.prospect_trace.make_call', [prospect_trace])
>>> make_call.form.description = 'Prospect told me to send him an email'
>>> make_call.form.interest = '3'
>>> make_call.form.schedule_call = 'yes'
>>> make_call.form.schedule_task = 'yes'
>>> make_call.execute('make_call')
>>> make_call.form.datetime = datetime(2023, 8, 14, 15, 30, 30)
>>> make_call.execute('schedule_call')
>>> make_call.form.task_description = 'I have to send a mail to prospect offering him this services...'
>>> make_call.execute('schedule_task')
>>> Task = Model.get('sale.pending_task')
>>> task, = Task.find([('description', '=', 'I have to send a mail to prospect offering him this services...')])
>>> task
proteus.Model.get('sale.pending_task')(1)
Hacer llamada y cerrar venta (Seguimiento de prospecto)::
>>> make_call = Wizard('sale.prospect_trace.make_call', [prospect_trace])
>>> make_call.form.description = 'Closed sale'

View File

@ -0,0 +1,7 @@
<?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>
<label name="task_description"/>
<field name="task_description"/>
</form>