Skip to content

Commit

Permalink
Merge 7defea6 into 3cf93ba
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrobaeza committed Feb 19, 2016
2 parents 3cf93ba + 7defea6 commit 037776a
Show file tree
Hide file tree
Showing 19 changed files with 515 additions and 0 deletions.
65 changes: 65 additions & 0 deletions crm_lead_to_event_registration/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3

====================================
Register a lead directly in an event
====================================

This module allows to register a lead directly in an event when converting
this lead into a partner, so that you can save several steps.

Usage
=====

Go to any lead in *Sales > Sales > Leads*, and click on the button "Convert
to Opportunity".

In the resulting screen, if the conversion action is "Convert to opportunity"
and you have selected a related partner (a new or an existing one), you will
have a section called "Event registration".

In that section, you can select an event, and when you click on
"Create opportunity", the partner will be registered automatically in the
event.

.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/199/8.0

Bug Tracker
===========

Bugs are tracked on `GitHub Issues
<https://github.com/OCA/event/issues>`_. In case of trouble, please
check there if your issue has already been reported. If you spotted it first,
help us smashing it by providing a detailed and welcomed `feedback
<https://github.com/OCA/
event/issues/new?body=module:%20
crm_lead_to_event_registration%0Aversion:%20
8.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Credits
=======

Contributors
------------

* Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
* Rafael Blasco <rafabn@antiun.com>
* Jairo Llopis <yajo.sk8@gmail.com>

Maintainer
----------

.. image:: http://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: http://odoo-community.org

This module is maintained by the OCA.

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

To contribute to this module, please visit http://odoo-community.org.
6 changes: 6 additions & 0 deletions crm_lead_to_event_registration/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# -*- coding: utf-8 -*-
# © 2016 Antiun Ingeniería S.L.
# © 2016 Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html

from . import models, wizard
32 changes: 32 additions & 0 deletions crm_lead_to_event_registration/__openerp__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# -*- coding: utf-8 -*-
# © 2016 Antiun Ingeniería S.L.
# © 2016 Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html

{
"name": "Register a lead directly in an event",
"version": "8.0.1.1.0",
"license": "AGPL-3",
"author": "Antiun Ingeniería S.L., "
"Serv. Tecnol. Avanzados - Pedro M. Baeza, "
"Odoo Community Association (OCA)",
"website": "https://www.antiun.com",
"category": "Event Management",
"images": [
"images/converting.png",
"images/not_linked.png",
"images/linked.png",
"images/linking.png",
],
"depends": [
'crm',
'event',
'marketing_crm',
],
"data": [
'wizard/crm_lead_event_pick_view.xml',
'wizard/crm_lead_to_opportunity_view.xml',
'views/crm_lead_view.xml',
],
"installable": True,
}
125 changes: 125 additions & 0 deletions crm_lead_to_event_registration/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * crm_lead_to_event_registration
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-02-19 16:38+0100\n"
"PO-Revision-Date: 2016-02-19 16:38+0100\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Poedit 1.8.6\n"

#. module: crm_lead_to_event_registration
#: view:crm.lead.event.pick:crm_lead_to_event_registration.event_pick_view
msgid "Accept"
msgstr "Aceptar"

#. module: crm_lead_to_event_registration
#: view:crm.lead.event.pick:crm_lead_to_event_registration.event_pick_view
msgid "Cancel"
msgstr "Cancelar"

#. module: crm_lead_to_event_registration
#: field:crm.lead2opportunity.partner,event_id:0
msgid "Create registration in this event"
msgstr "Crear registro en este evento"

#. module: crm_lead_to_event_registration
#: field:crm.lead.event.pick,create_uid:0
msgid "Created by"
msgstr "Creado por"

#. module: crm_lead_to_event_registration
#: field:crm.lead.event.pick,create_date:0
msgid "Created on"
msgstr "Creado el"

#. module: crm_lead_to_event_registration
#: field:crm.lead.event.pick,event_id:0
msgid "Event"
msgstr "Evento"

#. module: crm_lead_to_event_registration
#: field:crm.lead,event_registration_id:0
#: view:crm.lead2opportunity.partner:crm_lead_to_event_registration.view_crm_lead2opportunity_partner
msgid "Event registration"
msgstr "Registro del evento"

#. module: crm_lead_to_event_registration
#: help:crm.lead.event.pick,event_id:0
msgid "Event where the registration will be created."
msgstr "Evento en que se creará el registro."

#. module: crm_lead_to_event_registration
#: view:crm.lead:crm_lead_to_event_registration.view_crm_lead_form
#: view:crm.lead:crm_lead_to_event_registration.view_crm_opportunity_form
msgid "Generate registration"
msgstr "Generar registro"

#. module: crm_lead_to_event_registration
#: field:crm.lead.event.pick,id:0
msgid "ID"
msgstr "ID"

#. module: crm_lead_to_event_registration
#: field:crm.lead.event.pick,write_uid:0
msgid "Last Updated by"
msgstr "Última actualización por"

#. module: crm_lead_to_event_registration
#: field:crm.lead.event.pick,write_date:0
msgid "Last Updated on"
msgstr "Última actualización en"

#. module: crm_lead_to_event_registration
#: model:ir.model,name:crm_lead_to_event_registration.model_crm_lead2opportunity_partner
msgid "Lead To Opportunity Partner"
msgstr "Iniciativa/Oportunidad a Empresa"

#. module: crm_lead_to_event_registration
#: field:crm.lead.event.pick,lead_id:0
#: model:ir.model,name:crm_lead_to_event_registration.model_crm_lead
msgid "Lead/Opportunity"
msgstr "Iniciativa/Oportunidad"

#. module: crm_lead_to_event_registration
#: help:crm.lead.event.pick,lead_id:0
msgid "Lead/Opportunity from where to get contact information."
msgstr "Iniciativa/Oportunidad de la que extraer la información del contacto."

#. module: crm_lead_to_event_registration
#: model:ir.actions.act_window,name:crm_lead_to_event_registration.event_pick_action
msgid "Pick an event"
msgstr "Escoger un evento"

#. module: crm_lead_to_event_registration
#: help:crm.lead,event_registration_id:0
msgid "Registration generated by this lead/opportunity."
msgstr "Registro generado por esta iniciativa/oportunidad"

#. module: crm_lead_to_event_registration
#: view:crm.lead.event.pick:crm_lead_to_event_registration.event_pick_view
msgid "Select event to register"
msgstr "Seleccione un evento en el que registrar"

#. module: crm_lead_to_event_registration
#: code:addons/crm_lead_to_event_registration/models/crm_lead.py:27
#, python-format
msgid "You must set a name before generating a registration."
msgstr "Debe establecer un nombre antes de generar el registro"

#. module: crm_lead_to_event_registration
#: view:crm.lead.event.pick:crm_lead_to_event_registration.event_pick_view
msgid "or"
msgstr "o"

#~ msgid "You must a name before generating a registration."
#~ msgstr "Debe establecer un nombre antes de generar el registro"
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added crm_lead_to_event_registration/images/linked.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added crm_lead_to_event_registration/images/linking.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions crm_lead_to_event_registration/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
# © 2016 Antiun Ingeniería S.L. - Jairo Llopis
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from . import crm_lead
60 changes: 60 additions & 0 deletions crm_lead_to_event_registration/models/crm_lead.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# -*- coding: utf-8 -*-
# © 2016 Antiun Ingeniería S.L. - Jairo Llopis
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from openerp import _, api, exceptions, fields, models


class CrmLead(models.Model):
_inherit = "crm.lead"

event_registration_id = fields.Many2one(
"event.registration",
"Event registration",
readonly=True,
help="Registration generated by this lead/opportunity.")

@api.multi
def action_generate_event_registration(self, event):
"""Generate an event registration."""
er = self.env["event.registration"]
for s in self:
name = (s.contact_name or
s.partner_name or
s.partner_id.display_name)
if not name:
raise exceptions.ValidationError(
_("You must set a name before generating a registration."))
s.event_registration_id = er.create({
"event_id": event.id,
"partner_id": s.partner_id.id,
"nb_register": 1,
"name": name,
"email": s.email_from,
"phone": s.phone,
})
# Load data from partner if available
s.event_registration_id._onchange_partner()

@api.multi
def action_check_status_confirm_registration(self):
"""If the opportunity is won/lost, open/cancel registration."""
won = self._track["stage_id"]["crm.mt_lead_won"]
lost = self._track["stage_id"]["crm.mt_lead_lost"]
for s in self:
if won(s, s.env.cr, s.env.uid, s, s.env.context):
s.event_registration_id.registration_open()
elif lost(s, s.env.cr, s.env.uid, s, s.env.context):
s.event_registration_id.button_reg_cancel()

@api.model
def create(self, vals):
result = super(CrmLead, self).create(vals)
result.action_check_status_confirm_registration()
return result

@api.multi
def write(self, vals):
result = super(CrmLead, self).write(vals)
self.action_check_status_confirm_registration()
return result
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions crm_lead_to_event_registration/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# -*- coding: utf-8 -*-
# © 2016 Antiun Ingeniería S.L.
# © 2016 Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html

from . import test_crm_lead_to_event_registration
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# -*- coding: utf-8 -*-
# © 2016 Antiun Ingeniería S.L.
# © 2016 Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html

from openerp import fields
from openerp.tests import common


class TestCrmLeadToEventRegistration(common.TransactionCase):
def setUp(self):
super(TestCrmLeadToEventRegistration, self).setUp()
self.lead = self.env['crm.lead'].create({
'name': 'Test lead',
'partner_name': 'Test',
})
self.event = self.env['event.event'].create(
{'name': 'Test event',
'date_begin': fields.Date.today(),
'date_end': fields.Date.today()})
self.partner = self.env['res.partner'].create({'name': 'Test partner'})
self.registration = self.env['event.registration'].create(
{'event_id': self.event.id,
'partner_id': self.partner.id})
self.wiz_obj = self.env['crm.lead2opportunity.partner'].with_context(
active_ids=[self.lead.id], active_id=self.lead.id,
active_model='crm.lead')

def test_convert_lead_wo_partner(self):
wizard = self.wiz_obj.create({
'event_id': self.event.id,
'name': 'convert',
'action': 'create',
})
wizard.action_apply()
self.assertTrue(self.event.registration_ids)
self.assertTrue(self.event.registration_ids[0].partner_id)

def test_convert_lead_with_partner(self):
wizard = self.wiz_obj.create({
'event_id': self.event.id,
'name': 'convert',
'action': 'exist',
'partner_id': self.partner.id,
})
wizard.action_apply()
self.assertTrue(self.event.registration_ids)
self.assertEqual(
self.event.registration_ids[0].partner_id, self.partner)
Loading

0 comments on commit 037776a

Please sign in to comment.