Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add module crm_lead_website. #53

Merged
merged 6 commits into from
Oct 30, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
58 changes: 58 additions & 0 deletions crm_lead_website/README.rst
Original file line number Diff line number Diff line change
@@ -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 <https://github.com/OCA/crm/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 <https://github.com/OCA/ crm/issues/new?body=module:%20
crm_lead_website%0Aversion:%20
8.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.


Credits
=======

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

* Rafael Blasco <rafaelbn@antiun.com>
* Jairo Llopis <yajo.sk8@gmail.com>

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.
5 changes: 5 additions & 0 deletions crm_lead_website/__init__.py
Original file line number Diff line number Diff line change
@@ -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
20 changes: 20 additions & 0 deletions crm_lead_website/__openerp__.py
Original file line number Diff line number Diff line change
@@ -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",
],
}
27 changes: 27 additions & 0 deletions crm_lead_website/i18n/crm_lead_website.pot
Original file line number Diff line number Diff line change
@@ -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 ""

28 changes: 28 additions & 0 deletions crm_lead_website/i18n/es.po
Original file line number Diff line number Diff line change
@@ -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"
28 changes: 28 additions & 0 deletions crm_lead_website/models.py
Original file line number Diff line number Diff line change
@@ -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
Binary file added crm_lead_website/static/description/icon.png
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_website/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -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
29 changes: 29 additions & 0 deletions crm_lead_website/tests/test_lead.py
Original file line number Diff line number Diff line change
@@ -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)
32 changes: 32 additions & 0 deletions crm_lead_website/views/crm_lead.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>

<record model="ir.ui.view" id="lead_form_view">
<field name="name">Add website to lead</field>
<field name="model">crm.lead</field>
<field name="inherit_id" ref="crm.crm_case_form_view_leads"/>
<field name="arch" type="xml">
<data>
<xpath expr="//field[@name='fax']" position="after">
<field name="website"/>
</xpath>
</data>
</field>
</record>

<record model="ir.ui.view" id="opportunity_form_view">
<field name="name">Add website to opportunity</field>
<field name="model">crm.lead</field>
<field name="inherit_id" ref="crm.crm_case_form_view_oppor"/>
<field name="arch" type="xml">
<data>
<xpath expr="//field[@name='fax']" position="after">
<field name="website"/>
</xpath>
</data>
</field>
</record>

</data>
</openerp>