Error: Solo se guarda nuevo operario en primer iteración
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
This commit is contained in:
parent
416804983b
commit
e260c70a11
@ -21,11 +21,13 @@ def register():
|
||||
prospect.AssignOperatorStart,
|
||||
prospect_trace.ScheduleCallStart,
|
||||
prospect_trace.MakeCallStart,
|
||||
prospect.ReassignProspectByOperatorStart,
|
||||
module='sale_opportunity_management', type_='model')
|
||||
Pool.register(
|
||||
prospect_trace.ScheduleCall,
|
||||
prospect.AssignOperator,
|
||||
prospect_trace.MakeCall,
|
||||
prospect.ReassignProspectByOperator,
|
||||
module='sale_opportunity_management', type_='wizard')
|
||||
Pool.register(
|
||||
module='sale_opportunity_management', type_='report')
|
||||
|
44
prospect.py
44
prospect.py
@ -122,7 +122,7 @@ class AssignOperatorStart(ModelView):
|
||||
|
||||
operator = fields.Many2One('res.user', 'Operator', required=True)
|
||||
prospects = fields.One2Many(
|
||||
'sale.prospect', None, 'Prospects')
|
||||
'sale.prospect', None, 'Prospects', readonly=True)
|
||||
|
||||
business_unit = fields.Selection(
|
||||
[('brigade', 'Brigade'),
|
||||
@ -167,3 +167,45 @@ class AssignOperator(Wizard):
|
||||
prospect.save()
|
||||
|
||||
return 'end'
|
||||
|
||||
|
||||
class ReassignProspectByOperatorStart(ModelView):
|
||||
'Inicio de reasignación de prospecto por operario'
|
||||
__name__ = 'sale.prospect.reassign_by_operator.start'
|
||||
|
||||
current_operator = fields.Many2One('res.user', "Current operator")
|
||||
new_operator = fields.Many2One('res.user', "New operator")
|
||||
prospects = fields.One2Many(
|
||||
'sale.prospect', None, 'Prospects', readonly=True)
|
||||
|
||||
@fields.depends('current_operator', 'prospects')
|
||||
def on_change_current_operator(self):
|
||||
pool = Pool()
|
||||
Prospect = pool.get('sale.prospect')
|
||||
|
||||
self.prospects = []
|
||||
self.prospects = Prospect.search(
|
||||
[('state', '=', 'assigned'),
|
||||
('assigned_operator', '=', self.current_operator)])
|
||||
|
||||
|
||||
class ReassignProspectByOperator(Wizard):
|
||||
'Reasignar todos los prospectos de un operario, a otro operario'
|
||||
__name__ = 'sale.prospect.reassign_by_operator'
|
||||
|
||||
start = StateView(
|
||||
'sale.prospect.reassign_by_operator.start',
|
||||
'sale_opportunity_management.reassign_by_operator_start_view_form',
|
||||
[Button("Cancel", 'end', 'tryton-cancel'),
|
||||
Button(
|
||||
"Reassign", 'reassign_by_operator', 'tryton-ok', default=True)])
|
||||
|
||||
reassign_by_operator = StateTransition()
|
||||
|
||||
def transition_reassign_by_operator(self):
|
||||
for prospect in self.start.prospects:
|
||||
prospect.assigned_operator = self.start.new_operator
|
||||
prospect.save()
|
||||
|
||||
raise Exception(self.start.prospects[1].assigned_operator.name)
|
||||
return 'end'
|
||||
|
16
prospect.xml
16
prospect.xml
@ -148,5 +148,21 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="string">Start trace</field>
|
||||
<field name="model" search="[('model', '=', 'sale.prospect')]"/>
|
||||
</record>
|
||||
|
||||
|
||||
<record model="ir.action.wizard" id="reassign_by_operator_wizard">
|
||||
<field name="name">Reassign Operator</field>
|
||||
<field name="wiz_name">sale.prospect.reassign_by_operator</field>
|
||||
</record>
|
||||
<record model="ir.ui.view" id="reassign_by_operator_start_view_form">
|
||||
<field name="model">sale.prospect.reassign_by_operator.start</field>
|
||||
<field name="type">form</field>
|
||||
<field name="name">reassign_by_operator_form</field>
|
||||
</record>
|
||||
<record model="ir.action.keyword" id="reassign_by_operator_wizard_keyword">
|
||||
<field name="keyword">form_action</field>
|
||||
<field name="model">sale.prospect, -1</field>
|
||||
<field name="action" ref="reassign_by_operator_wizard"/>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
||||
|
@ -210,7 +210,7 @@ Crear llamadas a un seguimiento de prospecto::
|
||||
>>> make_call.form.interest = '3'
|
||||
>>> make_call.execute('make_call')
|
||||
|
||||
Verificar estado final del seguimiento del prospecto y sus llamadas
|
||||
Verificar estado final del seguimiento del prospecto y sus llamadas::
|
||||
>>> prospect_trace.calls[0].call_result
|
||||
'missed_call'
|
||||
>>> prospect_trace.calls[0].call_type
|
||||
@ -243,7 +243,7 @@ Programar una próxima llamada pendiente al seguimiento de prospecto::
|
||||
>>> prospect_trace.state
|
||||
'with_pending_calls'
|
||||
|
||||
Crear una llamada agendada previamente:
|
||||
Crear una llamada agendada previamente::
|
||||
>>> make_call = Wizard('sale.prospect_trace.make_call', [prospect_trace])
|
||||
>>> make_call.form.description = 'Fourth call to the prospect'
|
||||
>>> make_call.form.interest = '4'
|
||||
@ -255,7 +255,29 @@ Crear una llamada agendada previamente:
|
||||
'open'
|
||||
|
||||
|
||||
Reasignar prospectos por operador::
|
||||
>>> operator2 = User();
|
||||
>>> operator2.name = 'Operatus'
|
||||
>>> operator2.login = 'login'
|
||||
>>> operator2.save()
|
||||
|
||||
>>> reassign_by_operator = Wizard('sale.prospect.reassign_by_operator', [])
|
||||
>>> reassign_by_operator.form.current_operator = user
|
||||
>>> reassign_by_operator.form.prospects
|
||||
[proteus.Model.get('sale.prospect')(1), proteus.Model.get('sale.prospect')(2)]
|
||||
>>> reassign_by_operator.form.new_operator = operator2
|
||||
>>> reassign_by_operator.execute('reassign_by_operator')
|
||||
|
||||
>>> prospect1.assigned_operator.name
|
||||
'Operatus'
|
||||
>>> prospect2.assigned_operator.name
|
||||
'Operatus'
|
||||
>>> prospect_trace.prospect_assigned_operator.name
|
||||
'Operatus'
|
||||
|
||||
.. Las llamadas deben conservar el operador que las hizo
|
||||
>>> prospect_trace.calls[0].assigned_operator
|
||||
'Administrator'
|
||||
|
||||
--------
|
||||
Reportes
|
||||
|
6
view/reassign_by_operator_form.xml
Normal file
6
view/reassign_by_operator_form.xml
Normal 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>
|
Loading…
Reference in New Issue
Block a user