Se implementa wizard para crear llamada pendiente en las pruebas, #35

This commit is contained in:
Camilo Gonzalez 2023-08-19 12:41:29 -05:00
parent 3c4e8f5a26
commit 93c2f10040
5 changed files with 60 additions and 9 deletions

View File

@ -19,8 +19,10 @@ def register():
prospect.Prospect,
prospect_trace.ProspectTrace,
prospect.AssignOperatorStart,
prospect_trace.ScheduleCallStart,
module='sale_opportunity_management', type_='model')
Pool.register(
prospect_trace.ScheduleCall,
prospect.AssignOperator,
module='sale_opportunity_management', type_='wizard')
Pool.register(

View File

@ -1,5 +1,6 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
from trytond.wizard import Wizard, StateView, Button, StateTransition
from trytond.model import ModelSQL, ModelView, fields, DeactivableMixin
from trytond.pool import Pool
@ -58,11 +59,6 @@ class ProspectTrace(DeactivableMixin, ModelSQL, ModelView):
self.pending_call = None
self.state = 'open'
@fields.depends('pending_call', 'state')
def on_change_pending_call(self):
if self.pending_call:
self.state = 'with_pending_calls'
@fields.depends('prospect', 'prospect_city', 'prospect_contact')
def on_change_prospect(self):
if not self.prospect:
@ -95,3 +91,37 @@ class ProspectTrace(DeactivableMixin, ModelSQL, ModelView):
if contact_mobile:
return contact_mobile[0]
class ScheduleCallStart(ModelView):
'Inicio agendar llamada a seguimiento de prospecto'
__name__ = 'sale.prospect_trace.schedule.start'
date_time = fields.DateTime('Date time')
class ScheduleCall(Wizard):
'Agendar llamada a seguimiento de prospecto'
__name__ = 'sale.prospect_trace.schedule'
start = StateView(
'sale.prospect_trace.schedule.start',
'sale_opportunity_management.schedule_start_view_form', [
Button("Cancel", 'end', 'tryton-cancel'),
Button("Schedule", 'schedule', 'tryton-ok', default=True)])
schedule = StateTransition()
def transition_schedule(self):
pool = Pool()
PendingCall = pool.get('sale.pending_call')
pending_call = PendingCall()
pending_call.date = self.start.date_time
pending_call.save()
prospect_trace = self.record
prospect_trace.pending_call = pending_call
prospect_trace.state = 'with_pending_calls'
prospect_trace.save()
return 'end'

View File

@ -48,11 +48,18 @@ this repository contains the full copyright notices and license terms. -->
<field name="count" eval="True"/>
<field name="act_window" ref="act_prospect_trace_tree"/>
</record>
<menuitem
parent="menu_calls"
sequence="20"
id="menu_prospect_trace_tree"
action="act_prospect_trace_tree"/>
<!-- <record model="ir.action.wizard" id="schedule_call_wizard"> -->
<record model="ir.ui.view" id="schedule_start_view_form">
<field name="model">sale.prospect_trace.schedule.start</field>
<field name="type">form</field>
<field name="name">schedule_start_form</field>
</record>
</data>
</tryton>

View File

@ -218,9 +218,15 @@ Verificar estado final del seguimiento del prospecto y sus llamadas
Programar una próxima llamada pendiente al seguimiento de prospecto::
>>> PendingCall = Model.get('sale.pending_call')
>>> pending_call = PendingCall()
>>> pending_call.date = datetime(2023, 8, 14, 15, 30, 30)
>>> prospect_trace.pending_call = pending_call
.. >>> pending_call = PendingCall()
>>> schedule = Wizard('sale.prospect_trace.schedule', [prospect_trace])
>>> schedule.form.date_time = datetime(2023, 8, 14, 15, 30, 30)
>>> schedule.execute('schedule')
.. >>> pending_call.date = datetime(2023, 8, 14, 15, 30, 30)
.. >>> prospect_trace.pending_call = pending_call
>>> prospect_trace.pending_call.date
datetime.datetime(2023, 8, 14, 15, 30, 30)

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>