diff --git a/.gitignore b/.gitignore index 98f5b2d..fa62fc5 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,8 @@ __pycache__/ *$py.class *.bk +/.vscode + # C extensions *.so diff --git a/__init__.py b/__init__.py index 2759f8e..79203eb 100644 --- a/__init__.py +++ b/__init__.py @@ -1,10 +1,17 @@ from trytond.pool import Pool +from . import prospect +from . import prospect_trace +from . import call __all__ = ['register'] def register(): Pool.register( + call.Call, + prospect.Prospect, + prospect.ContactMethod, + prospect_trace.ProspectTrace, module='sale_opportunity_management', type_='model') Pool.register( module='sale_opportunity_management', type_='wizard') diff --git a/call.py b/call.py new file mode 100644 index 0000000..57e2d0a --- /dev/null +++ b/call.py @@ -0,0 +1,16 @@ +from trytond.model import ModelSQL, ModelView, fields +from datetime import date + +class Call(ModelSQL, ModelView): + 'Llamada' + + __name__ = 'sale.call' + + date = fields.Date('Date') + description = fields.Char('Description') + + prospect_trace = fields.Many2One('sale.prospect_trace', 'Prospect track') + + @classmethod + def default_date(cls): + return date.today() \ No newline at end of file diff --git a/call.xml b/call.xml new file mode 100644 index 0000000..fbdd32a --- /dev/null +++ b/call.xml @@ -0,0 +1,43 @@ + + + + + + Calls + sale.call + + + + sale.call + tree + call_tree + + + sale.call + form + call_form + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/doc/es/calls.rst b/doc/es/calls.rst index e8901e7..0ff7fa2 100644 --- a/doc/es/calls.rst +++ b/doc/es/calls.rst @@ -57,8 +57,7 @@ Seguimiento de prospecto 2 * 1 - total desinterés * 2 - Interés intermedio, brindar mas información * 3 - Interés alto, generar venta - - * Estado (realizada - pendiente) + * Seguimiento de prospecto al que pertence -------- diff --git a/prospect.py b/prospect.py new file mode 100644 index 0000000..c605a2a --- /dev/null +++ b/prospect.py @@ -0,0 +1,29 @@ +# 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.model import ModelSQL, ModelView, fields + +class Prospect(ModelSQL, ModelView): + 'Prospecto' + __name__ = 'sale.prospect' + + name = fields.Char('Name') + city = fields.Char('City') + + contact_methods = fields.One2Many('prospect.contact_method', 'prospect', 'Contact methods') + + +class ContactMethod(ModelSQL, ModelView): + 'Mecanismo de contacto' + __name__ = 'prospect.contact_method' + + _type = [ + ('phone', 'Phone'), + ('mobile', 'Mobile'), + ('email', 'Email') + ] + contact_type = fields.Selection(_type, 'Contact type') + + value = fields.Char('Value') + + prospect = fields.Many2One('sale.prospect', 'Prospect') + diff --git a/prospect.xml b/prospect.xml new file mode 100644 index 0000000..3bb663a --- /dev/null +++ b/prospect.xml @@ -0,0 +1,39 @@ + + + + + + Prospects + sale.prospect + + + + sale.prospect + tree + prospect_tree + + + sale.prospect + form + prospect_form + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/prospect_trace.py b/prospect_trace.py new file mode 100644 index 0000000..4506e41 --- /dev/null +++ b/prospect_trace.py @@ -0,0 +1,22 @@ +# 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.model import ModelSQL, ModelView, fields + +class ProspectTrace(ModelSQL, ModelView): + 'Seguimiento de un prospecto' + + __name__ = 'sale.prospect_trace' + + prospect = fields.Many2One('sale.prospect', 'Prospect') + prospect_name = fields.Char('Name') + prospect_contact = fields.Char('Contact') + prospect_city = fields.Char('City') + + calls = fields.One2Many('sale.call', 'prospect_trace', "Calls") + + @fields.depends('prospect') + def on_change_prospect(self): + if self.prospect: + self.prospect_name = self.prospect.name + # self.prospect_contact = self.prospect.contact_methods.index('contact_type 'mobile') + self.prospect_city = self.prospect.city diff --git a/prospect_trace.xml b/prospect_trace.xml new file mode 100644 index 0000000..e06663b --- /dev/null +++ b/prospect_trace.xml @@ -0,0 +1,39 @@ + + + + + + Prospect Traces + sale.prospect_trace + + + + sale.prospect_trace + tree + prospect_trace_tree + + + sale.prospect_trace + form + prospect_trace_form + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/scenario_sale_opportunity_management.rst b/tests/scenario_sale_opportunity_management.rst index 6669776..32f0888 100644 --- a/tests/scenario_sale_opportunity_management.rst +++ b/tests/scenario_sale_opportunity_management.rst @@ -6,7 +6,78 @@ Imports:: >>> from proteus import Model, Wizard >>> from trytond.tests.tools import activate_modules + >>> from datetime import date Activate modules:: >>> config = activate_modules('sale_opportunity_management') + +--------------------------------------------------------------------------------------------- +Como administrador quiero registrar un prospecto para lugo poder hacerle un seguimiento +--------------------------------------------------------------------------------------------- + +Crear mecanismos de contacto:: + + +Crear prospecto:: + >>> Prospect = Model.get('sale.prospect') + >>> prospect = Prospect() + + >>> prospect.name = 'guchito S.A.S' + >>> prospect.city = 'Bogotá' + >>> phone = prospect.contact_methods.new() + >>> phone.contact_type = 'mobile' + >>> phone.value = '3132923938' + >>> prospect.save() + + + +----------------------------------------------------------------------------------------- +Como operador quiero poder crear un seguimiento de prospecto para luego hacer una llamada +----------------------------------------------------------------------------------------- + +Crear seguimiento de prospecto:: + >>> ProspectTrace = Model.get('sale.prospect_trace') + >>> prospect_trace = ProspectTrace() + + >>> prospect_trace.prospect = prospect + >>> prospect_trace.save() + + >>> prospect_trace.prospect_name + 'guchito S.A.S' + >>> prospect_trace.prospect_city + 'Bogotá' + +---------------------------------------------------------------------------- +Como operador quiero registrar una llamada para luego generar reportes +---------------------------------------------------------------------------- + +Crear llamada a un seguimiento de prospecto:: + >>> Call = Model.get('sale.call') + >>> call = Call() + + >>> call.description = 'Descripción u observaciones de la llamada' + >>> call.prospect_trace = prospect_trace + >>> call.save() + + >>> call.prospect_trace.prospect_name + 'guchito S.A.S' + >>> call.date == date.today() + True + +Crear otra llamada al mismo seguimiento de prospecto:: + >>> Call = Model.get('sale.call') + >>> call = Call() + + >>> call.description = 'Segunda llamada al mismo seguimiento' + >>> call.prospect_trace = prospect_trace + >>> call.save() + + >>> call.prospect_trace.prospect_name + 'guchito S.A.S' + >>> call.prospect_trace.prospect_city + 'Bogotá' + >>> call.date == date.today() + True + >>> len(prospect_trace.calls) == 2 + True \ No newline at end of file diff --git a/tryton.cfg b/tryton.cfg index f6aeab7..98e91c6 100644 --- a/tryton.cfg +++ b/tryton.cfg @@ -3,3 +3,6 @@ version=6.8.0 depends: ir xml: + call.xml + prospect_trace.xml + prospect.xml \ No newline at end of file diff --git a/view/call_form.xml b/view/call_form.xml new file mode 100644 index 0000000..76a00ab --- /dev/null +++ b/view/call_form.xml @@ -0,0 +1,13 @@ + + +
+