diff --git a/crm_lead_invoice_address/README.rst b/crm_lead_invoice_address/README.rst new file mode 100644 index 000000000000..d896da2c2077 --- /dev/null +++ b/crm_lead_invoice_address/README.rst @@ -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 `_. 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_invoice_address/__init__.py b/crm_lead_invoice_address/__init__.py new file mode 100644 index 000000000000..49bb330e0df1 --- /dev/null +++ b/crm_lead_invoice_address/__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_invoice_address/__openerp__.py b/crm_lead_invoice_address/__openerp__.py new file mode 100644 index 000000000000..5add937e8642 --- /dev/null +++ b/crm_lead_invoice_address/__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": "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", + ], +} diff --git a/crm_lead_invoice_address/i18n/crm_lead_invoice_address.pot b/crm_lead_invoice_address/i18n/crm_lead_invoice_address.pot new file mode 100644 index 000000000000..536d98a87062 --- /dev/null +++ b/crm_lead_invoice_address/i18n/crm_lead_invoice_address.pot @@ -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 "" + diff --git a/crm_lead_invoice_address/i18n/es.po b/crm_lead_invoice_address/i18n/es.po new file mode 100644 index 000000000000..d63f3de361e9 --- /dev/null +++ b/crm_lead_invoice_address/i18n/es.po @@ -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" diff --git a/crm_lead_invoice_address/models.py b/crm_lead_invoice_address/models.py new file mode 100644 index 000000000000..47290414d471 --- /dev/null +++ b/crm_lead_invoice_address/models.py @@ -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 diff --git a/crm_lead_invoice_address/static/description/icon.png b/crm_lead_invoice_address/static/description/icon.png new file mode 100644 index 000000000000..3a0328b516c4 Binary files /dev/null and b/crm_lead_invoice_address/static/description/icon.png differ diff --git a/crm_lead_invoice_address/tests/__init__.py b/crm_lead_invoice_address/tests/__init__.py new file mode 100644 index 000000000000..a2e800a5ce11 --- /dev/null +++ b/crm_lead_invoice_address/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_invoice_address/tests/test_lead.py b/crm_lead_invoice_address/tests/test_lead.py new file mode 100644 index 000000000000..c1b568401285 --- /dev/null +++ b/crm_lead_invoice_address/tests/test_lead.py @@ -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) diff --git a/crm_lead_invoice_address/views/crm_lead.xml b/crm_lead_invoice_address/views/crm_lead.xml new file mode 100644 index 000000000000..81579efd2665 --- /dev/null +++ b/crm_lead_invoice_address/views/crm_lead.xml @@ -0,0 +1,45 @@ + + + + + + Add invoice address to lead + crm.lead + + + + + + +
+
+
+
+
+
+
+ +
+