diff --git a/__init__.py b/__init__.py
index e4c2bb7..9ecc15a 100644
--- a/__init__.py
+++ b/__init__.py
@@ -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')
diff --git a/pending_call.py b/pending_call.py
index fe78bc3..7b7af9a 100644
--- a/pending_call.py
+++ b/pending_call.py
@@ -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
diff --git a/prospect_trace.py b/prospect_trace.py
index 5bb6bd5..d1c072d 100644
--- a/prospect_trace.py
+++ b/prospect_trace.py
@@ -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()
diff --git a/prospect_trace.xml b/prospect_trace.xml
index 2c429d0..b2310c5 100644
--- a/prospect_trace.xml
+++ b/prospect_trace.xml
@@ -132,6 +132,11 @@ this repository contains the full copyright notices and license terms. -->
form
make_call_ask_form
+
+ sale.prospect_trace.make_call.ask_task
+ form
+ make_call_ask_task_form
+
wizard_make_call
Make call
diff --git a/tests/scenario_sale_opportunity_management.rst b/tests/scenario_sale_opportunity_management.rst
index 3d17722..315f2ea 100644
--- a/tests/scenario_sale_opportunity_management.rst
+++ b/tests/scenario_sale_opportunity_management.rst
@@ -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'
diff --git a/view/make_call_ask_task_form.xml b/view/make_call_ask_task_form.xml
new file mode 100644
index 0000000..049a1d2
--- /dev/null
+++ b/view/make_call_ask_task_form.xml
@@ -0,0 +1,7 @@
+
+
+