Skip to content

Commit

Permalink
Merge d473e62 into 17be632
Browse files Browse the repository at this point in the history
  • Loading branch information
yajo committed Oct 6, 2015
2 parents 17be632 + d473e62 commit e81ee60
Show file tree
Hide file tree
Showing 10 changed files with 428 additions and 0 deletions.
64 changes: 64 additions & 0 deletions crm_lead_invoice_address/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
.. 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

============
Invoice address in leads
============

This module was written to extend the functionality of CRM leads to support
setting a separate invoice address.

Usage
=====

To use this module, you need to:

* Go to *Sales > Leads*.
* Open a lead.
* Go to *Extra Info*.
* You will see the new group called *Invoice address*.
* If you uncheck *Use same adress for billing*, you will be able to specify a
different address for billing purposes.

The company partner that gets automatically created from that lead will have
an internal *type* of ``invoice``.

.. image:: https://odoo-community.org/invoice address/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_invoice address%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_invoice_address/__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_invoice_address/__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": "Invoice address in leads",
"summary": "Add Invoice address field to leads",
"version": "8.0.1.0.0",
"category": "Customer Relationship Management",
"invoice address": "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",
],
}
97 changes: 97 additions & 0 deletions crm_lead_invoice_address/i18n/crm_lead_invoice_address.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * crm_lead_invoice_address
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-10-06 16:32+0000\n"
"PO-Revision-Date: 2015-10-06 16:32+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_invoice_address
#: view:crm.lead:crm_lead_invoice_address.form_view
msgid "Address"
msgstr ""

#. module: crm_lead_invoice_address
#: view:crm.lead:crm_lead_invoice_address.form_view
msgid "City"
msgstr ""

#. module: crm_lead_invoice_address
#: view:crm.lead:crm_lead_invoice_address.form_view
msgid "Country"
msgstr ""

#. module: crm_lead_invoice_address
#: view:crm.lead:crm_lead_invoice_address.form_view
msgid "Invoice address"
msgstr ""

#. module: crm_lead_invoice_address
#: field:crm.lead,invoice_zip:0
msgid "Invoice address ZIP code"
msgstr ""

#. module: crm_lead_invoice_address
#: field:crm.lead,invoice_city:0
msgid "Invoice address city"
msgstr ""

#. module: crm_lead_invoice_address
#: field:crm.lead,invoice_country_id:0
msgid "Invoice address country"
msgstr ""

#. module: crm_lead_invoice_address
#: field:crm.lead,invoice_state_id:0
msgid "Invoice address state"
msgstr ""

#. module: crm_lead_invoice_address
#: field:crm.lead,invoice_street:0
msgid "Invoice address street"
msgstr ""

#. module: crm_lead_invoice_address
#: field:crm.lead,invoice_street2:0
msgid "Invoice address street 2"
msgstr ""

#. module: crm_lead_invoice_address
#: model:ir.model,name:crm_lead_invoice_address.model_crm_lead
msgid "Lead/Opportunity"
msgstr ""

#. module: crm_lead_invoice_address
#: view:crm.lead:crm_lead_invoice_address.form_view
msgid "State"
msgstr ""

#. module: crm_lead_invoice_address
#: view:crm.lead:crm_lead_invoice_address.form_view
msgid "Street..."
msgstr ""

#. module: crm_lead_invoice_address
#: help:crm.lead,invoice_equal:0
msgid "Uncheck this option to specify a different billing address."
msgstr ""

#. module: crm_lead_invoice_address
#: field:crm.lead,invoice_equal:0
msgid "Use same adress for billing"
msgstr ""

#. module: crm_lead_invoice_address
#: view:crm.lead:crm_lead_invoice_address.form_view
msgid "ZIP"
msgstr ""

98 changes: 98 additions & 0 deletions crm_lead_invoice_address/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * crm_lead_invoice_address
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-10-06 18:33+0200\n"
"PO-Revision-Date: 2015-10-06 18:34+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_invoice_address
#: view:crm.lead:crm_lead_invoice_address.form_view
msgid "Address"
msgstr "Dirección"

#. module: crm_lead_invoice_address
#: view:crm.lead:crm_lead_invoice_address.form_view
msgid "City"
msgstr "Ciudad"

#. module: crm_lead_invoice_address
#: view:crm.lead:crm_lead_invoice_address.form_view
msgid "Country"
msgstr "País"

#. module: crm_lead_invoice_address
#: view:crm.lead:crm_lead_invoice_address.form_view
msgid "Invoice address"
msgstr "Dirección de facturación"

#. module: crm_lead_invoice_address
#: field:crm.lead,invoice_zip:0
msgid "Invoice address ZIP code"
msgstr "CP de la dirección de facturación"

#. module: crm_lead_invoice_address
#: field:crm.lead,invoice_city:0
msgid "Invoice address city"
msgstr "Ciudad de la dirección de facturación"

#. module: crm_lead_invoice_address
#: field:crm.lead,invoice_country_id:0
msgid "Invoice address country"
msgstr "País de la dirección de facturación"

#. module: crm_lead_invoice_address
#: field:crm.lead,invoice_state_id:0
msgid "Invoice address state"
msgstr "Provincia de la dirección de facturación"

#. module: crm_lead_invoice_address
#: field:crm.lead,invoice_street:0
msgid "Invoice address street"
msgstr "Calle de la dirección de facturación"

#. module: crm_lead_invoice_address
#: field:crm.lead,invoice_street2:0
msgid "Invoice address street 2"
msgstr "Calle 2 de la dirección de facturación"

#. module: crm_lead_invoice_address
#: model:ir.model,name:crm_lead_invoice_address.model_crm_lead
msgid "Lead/Opportunity"
msgstr "Iniciativa/Oportunidad"

#. module: crm_lead_invoice_address
#: view:crm.lead:crm_lead_invoice_address.form_view
msgid "State"
msgstr "Provincia"

#. module: crm_lead_invoice_address
#: view:crm.lead:crm_lead_invoice_address.form_view
msgid "Street..."
msgstr "Calle..."

#. module: crm_lead_invoice_address
#: help:crm.lead,invoice_equal:0
msgid "Uncheck this option to specify a different billing address."
msgstr "Desactive esta opción para especificar una dirección de facturación diferente."

#. module: crm_lead_invoice_address
#: field:crm.lead,invoice_equal:0
msgid "Use same adress for billing"
msgstr "Usar la misma dirección para la facturación"

#. module: crm_lead_invoice_address
#: view:crm.lead:crm_lead_invoice_address.form_view
msgid "ZIP"
msgstr "CP"
52 changes: 52 additions & 0 deletions crm_lead_invoice_address/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# -*- 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"

invoice_equal = fields.Boolean(
"Use same adress for billing",
default=True,
help="Uncheck this option to specify a different billing address.")
invoice_street = fields.Char("Invoice address street")
invoice_street2 = fields.Char("Invoice address street 2")
invoice_city = fields.Char("Invoice address city")
invoice_state_id = fields.Many2one("res.country.state",
"Invoice address state")
invoice_zip = fields.Char("Invoice address ZIP code")
invoice_country_id = fields.Many2one("res.country",
"Invoice address country")

@api.one
def _map_values_to_partner(self, name, is_company, *args, **kwargs):
"""Add invoice address to mapped values."""
result = super(Lead, self)._map_values_to_partner(
name, is_company, *args, **kwargs)[0]

if is_company and not self.invoice_equal:
result.update({
"type": "invoice",
"street": self.invoice_street or result.get("street"),
"street2": self.invoice_street2 or result.get("street2"),
"zip": self.invoice_zip or result.get("zip"),
"city": self.invoice_city or result.get("city"),
"state_id": (self.invoice_state_id and
self.invoice_state_id.id or
result.get("state_id")),
"country_id": (self.invoice_country_id and
self.invoice_country_id.id or
result.get("country_id")),
})

return result

@api.one
@api.onchange("invoice_state_id")
def _invoice_state_id_change(self):
"""Update country in UI."""
if self.invoice_state_id:
self.invoice_country_id = self.invoice_state_id.country_id
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_invoice_address/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
42 changes: 42 additions & 0 deletions crm_lead_invoice_address/tests/test_lead.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# -*- 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__,
"invoice_equal": False,
})
self.partner = self.env["res.partner"].create({"name": __file__})

def test_mapped_values(self):
"""Invoice address gets mapped when creating partner."""
self.lead.invoice_street = "invoice_street"
self.lead.invoice_street2 = "invoice_street2"
self.lead.invoice_city = "invoice_city"
self.lead.invoice_zip = "invoice_zip"
self.lead.invoice_state_id = self.env.ref("base.state_us_2")
self.lead.invoice_country_id = self.env.ref("base.us")

mapped = self.lead._map_values_to_partner(self.lead.name, True)[0]

self.assertEqual(mapped["type"], "invoice")
self.assertEqual(mapped["street"], self.lead.invoice_street)
self.assertEqual(mapped["street2"], self.lead.invoice_street2)
self.assertEqual(mapped["city"], self.lead.invoice_city)
self.assertEqual(mapped["zip"], self.lead.invoice_zip)
self.assertEqual(mapped["state_id"], self.lead.invoice_state_id.id)
self.assertEqual(mapped["country_id"], self.lead.invoice_country_id.id)

def test_state_id_change(self):
"""Country reflects state change."""
state = self.env.ref("base.state_us_2")
self.lead.invoice_state_id = state
self.lead._invoice_state_id_change()

self.assertEqual(self.lead.invoice_country_id, state.country_id)

0 comments on commit e81ee60

Please sign in to comment.