diff --git a/crm_lead_website/README.rst b/crm_lead_website/README.rst new file mode 100644 index 00000000000..791e112bc2d --- /dev/null +++ b/crm_lead_website/README.rst @@ -0,0 +1,58 @@ +.. 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 + +============ +Website in leads +============ + +This module was written to extend the functionality of CRM leads to support +setting the website. + +Usage +===== + +To use this module, you need to: + +* Go to *Sales > Leads*. +* Open a lead. +* You will see the new field. + +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/111/8.0 + +Bug Tracker +=========== + +Bugs are tracked on `GitHub 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 `here `_. + + +Credits +======= + +Contributors +------------ + +* Rafael Blasco +* Jairo Llopis + +Maintainer +---------- + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://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. diff --git a/crm_lead_website/__init__.py b/crm_lead_website/__init__.py new file mode 100644 index 00000000000..49bb330e0df --- /dev/null +++ b/crm_lead_website/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# © 2015 Antiun Ingeniería, S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import models diff --git a/crm_lead_website/__openerp__.py b/crm_lead_website/__openerp__.py new file mode 100644 index 00000000000..1c6717e3ecb --- /dev/null +++ b/crm_lead_website/__openerp__.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# © 2015 Antiun Ingeniería, S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +{ + "name": "Website in leads", + "summary": "Add Website field to leads", + "version": "8.0.1.0.0", + "category": "Customer Relationship Management", + "website": "https://odoo-community.org/", + "author": "Antiun Ingeniería, S.L., Odoo Community Association (OCA)", + "license": "AGPL-3", + "application": False, + "installable": True, + "depends": [ + "crm", + ], + "data": [ + "views/crm_lead.xml", + ], +} diff --git a/crm_lead_website/i18n/crm_lead_website.pot b/crm_lead_website/i18n/crm_lead_website.pot new file mode 100644 index 00000000000..c5c7fcfa813 --- /dev/null +++ b/crm_lead_website/i18n/crm_lead_website.pot @@ -0,0 +1,27 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * crm_lead_website +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-10-06 15:49+0000\n" +"PO-Revision-Date: 2015-10-06 15:49+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: crm_lead_website +#: model:ir.model,name:crm_lead_website.model_crm_lead +msgid "Lead/Opportunity" +msgstr "" + +#. module: crm_lead_website +#: field:crm.lead,website:0 +msgid "Website" +msgstr "" + diff --git a/crm_lead_website/i18n/es.po b/crm_lead_website/i18n/es.po new file mode 100644 index 00000000000..db5e6c88475 --- /dev/null +++ b/crm_lead_website/i18n/es.po @@ -0,0 +1,28 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * crm_lead_website +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-10-06 17:50+0200\n" +"PO-Revision-Date: 2015-10-06 17:50+0200\n" +"Language-Team: \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.4\n" +"Last-Translator: \n" +"Language: es\n" + +#. module: crm_lead_website +#: model:ir.model,name:crm_lead_website.model_crm_lead +msgid "Lead/Opportunity" +msgstr "Iniciativa/Oportunidad" + +#. module: crm_lead_website +#: field:crm.lead,website:0 +msgid "Website" +msgstr "Sitio web" diff --git a/crm_lead_website/models.py b/crm_lead_website/models.py new file mode 100644 index 00000000000..2290345cb33 --- /dev/null +++ b/crm_lead_website/models.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +# © 2015 Antiun Ingeniería, S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from openerp import api, fields, models + + +class Lead(models.Model): + _inherit = "crm.lead" + + website = fields.Char() + + @api.model + def _lead_create_contact(self, lead, name, is_company, parent_id=False): + """Add trade name to partner.""" + return (super(Lead, self.with_context(default_website=lead.website)) + ._lead_create_contact(lead, name, is_company, parent_id)) + + @api.multi + def on_change_partner_id(self, partner_id): + """Recover website from partner if available.""" + result = super(Lead, self).on_change_partner_id(partner_id) + + if result.get("value"): + if self.partner_id and self.partner_id.website: + result["value"]["website"] = self.partner_id.website + + return result diff --git a/crm_lead_website/static/description/icon.png b/crm_lead_website/static/description/icon.png new file mode 100644 index 00000000000..3a0328b516c Binary files /dev/null and b/crm_lead_website/static/description/icon.png differ diff --git a/crm_lead_website/tests/__init__.py b/crm_lead_website/tests/__init__.py new file mode 100644 index 00000000000..a2e800a5ce1 --- /dev/null +++ b/crm_lead_website/tests/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# © 2015 Antiun Ingeniería, S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import test_lead diff --git a/crm_lead_website/tests/test_lead.py b/crm_lead_website/tests/test_lead.py new file mode 100644 index 00000000000..b5b9dbe5490 --- /dev/null +++ b/crm_lead_website/tests/test_lead.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- +# © 2015 Antiun Ingeniería, S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from openerp.tests.common import TransactionCase + + +class LeadCase(TransactionCase): + def setUp(self): + super(LeadCase, self).setUp() + self.lead = self.env["crm.lead"].create({ + "name": __file__, + "partner_name": u"HÎ" + }) + self.partner = self.env["res.partner"].create({"name": __file__}) + self.test_field = "http://antiun.net" + + def test_transfered_values(self): + """Field gets transfered when creating partner.""" + self.lead.website = self.test_field + self.lead.handle_partner_assignation() + self.assertEqual(self.lead.partner_id.website, self.test_field) + + def test_onchange_partner_id(self): + """Lead gets website from partner when linked to it.""" + self.partner.website = self.test_field + self.lead.partner_id = self.partner + result = self.lead.on_change_partner_id(self.partner.id) + self.assertEqual(result["value"]["website"], self.test_field) diff --git a/crm_lead_website/views/crm_lead.xml b/crm_lead_website/views/crm_lead.xml new file mode 100644 index 00000000000..7673ab5061d --- /dev/null +++ b/crm_lead_website/views/crm_lead.xml @@ -0,0 +1,32 @@ + + + + + + Add website to lead + crm.lead + + + + + + + + + + + + Add website to opportunity + crm.lead + + + + + + + + + + + +