diff --git a/l10n_us_crm_county/README.rst b/l10n_us_crm_county/README.rst new file mode 100644 index 00000000..2ccf758c --- /dev/null +++ b/l10n_us_crm_county/README.rst @@ -0,0 +1,81 @@ +.. image:: https://odoo-community.org/readme-banner-image + :target: https://odoo-community.org/get-involved?utm_source=readme + :alt: Odoo Community Association + +======================== +United States - Counties +======================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:3eb5da1de3d3f90e53c68b57bf0229bbd10c3b9596d6a6325142b886ba08efc7 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/license-LGPL--3-blue.png + :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html + :alt: License: LGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fl10n--usa-lightgray.png?logo=github + :target: https://github.com/OCA/l10n-usa/tree/19.0/l10n_us_crm_county + :alt: OCA/l10n-usa +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/l10n-usa-19-0/l10n-usa-19-0-l10n_us_crm_county + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/l10n-usa&target_branch=19.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Imported from U.S. Census Bureau data. +https://www.census.gov/library/publications/2011/compendia/usa-counties-2011.html + +**Table of contents** + +.. contents:: + :local: + +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 to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* MetricWise + +Contributors +------------ + +- Adam Heinz + +Maintainers +----------- + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +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. + +This module is part of the `OCA/l10n-usa `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/l10n_us_crm_county/__init__.py b/l10n_us_crm_county/__init__.py new file mode 100644 index 00000000..0650744f --- /dev/null +++ b/l10n_us_crm_county/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/l10n_us_crm_county/__manifest__.py b/l10n_us_crm_county/__manifest__.py new file mode 100644 index 00000000..d109c938 --- /dev/null +++ b/l10n_us_crm_county/__manifest__.py @@ -0,0 +1,17 @@ +{ + "name": "United States - Counties", + "version": "19.0.1.0.0", + "category": "Localization", + "summary": "Add United States counties to leads.", + "author": "MetricWise, Odoo Community Association (OCA)", + "license": "LGPL-3", + "maintainer": "Adam Heinz ", + "website": "https://github.com/OCA/l10n-usa", + "depends": [ + "crm", + "l10n_us_base_county", + ], + "data": [ + "views/crm_lead_views.xml", + ], +} diff --git a/l10n_us_crm_county/i18n/l10n_us_crm_county.pot b/l10n_us_crm_county/i18n/l10n_us_crm_county.pot new file mode 100644 index 00000000..4b8752a3 --- /dev/null +++ b/l10n_us_crm_county/i18n/l10n_us_crm_county.pot @@ -0,0 +1,25 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * l10n_us_crm_county +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.0\n" +"Report-Msgid-Bugs-To: \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: l10n_us_crm_county +#: model:ir.model.fields,field_description:l10n_us_crm_county.field_crm_lead__county_id +#: model_terms:ir.ui.view,arch_db:l10n_us_crm_county.crm_lead_view_form +msgid "County" +msgstr "" + +#. module: l10n_us_crm_county +#: model:ir.model,name:l10n_us_crm_county.model_crm_lead +msgid "Lead/Opportunity" +msgstr "" diff --git a/l10n_us_crm_county/models/__init__.py b/l10n_us_crm_county/models/__init__.py new file mode 100644 index 00000000..e66f0d6c --- /dev/null +++ b/l10n_us_crm_county/models/__init__.py @@ -0,0 +1 @@ +from . import crm_lead diff --git a/l10n_us_crm_county/models/crm_lead.py b/l10n_us_crm_county/models/crm_lead.py new file mode 100644 index 00000000..9cd906ed --- /dev/null +++ b/l10n_us_crm_county/models/crm_lead.py @@ -0,0 +1,24 @@ +from odoo import fields, models + +from odoo.addons.crm.models.crm_lead import PARTNER_ADDRESS_FIELDS_TO_SYNC + +PARTNER_ADDRESS_FIELDS_TO_SYNC.extend(["county_id"]) + + +class Lead(models.Model): + _inherit = "crm.lead" + + county_id = fields.Many2one( + "res.country.state.county", + compute="_compute_partner_address_values", + domain="[('state_id', '=', state_id)]", + ondelete="restrict", + readonly=False, + store=True, + ) + + # Override + def _prepare_customer_values(self, partner_name, is_company, parent_id=False): + values = super()._prepare_customer_values(partner_name, is_company, parent_id) + values["county_id"] = self.county_id.id + return values diff --git a/l10n_us_crm_county/pyproject.toml b/l10n_us_crm_county/pyproject.toml new file mode 100644 index 00000000..4231d0cc --- /dev/null +++ b/l10n_us_crm_county/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/l10n_us_crm_county/readme/CONTRIBUTORS.md b/l10n_us_crm_county/readme/CONTRIBUTORS.md new file mode 100644 index 00000000..a748201f --- /dev/null +++ b/l10n_us_crm_county/readme/CONTRIBUTORS.md @@ -0,0 +1 @@ +- Adam Heinz \<\> diff --git a/l10n_us_crm_county/readme/DESCRIPTION.md b/l10n_us_crm_county/readme/DESCRIPTION.md new file mode 100644 index 00000000..46fc6a3f --- /dev/null +++ b/l10n_us_crm_county/readme/DESCRIPTION.md @@ -0,0 +1,2 @@ +Imported from U.S. Census Bureau data. +https://www.census.gov/library/publications/2011/compendia/usa-counties-2011.html diff --git a/l10n_us_crm_county/static/description/icon.png b/l10n_us_crm_county/static/description/icon.png new file mode 100644 index 00000000..1dcc49c2 Binary files /dev/null and b/l10n_us_crm_county/static/description/icon.png differ diff --git a/l10n_us_crm_county/static/description/index.html b/l10n_us_crm_county/static/description/index.html new file mode 100644 index 00000000..3aa989f8 --- /dev/null +++ b/l10n_us_crm_county/static/description/index.html @@ -0,0 +1,430 @@ + + + + + +README.rst + + + +
+ + + +Odoo Community Association + +
+

United States - Counties

+ +

Beta License: LGPL-3 OCA/l10n-usa Translate me on Weblate Try me on Runboat

+

Imported from U.S. Census Bureau data. +https://www.census.gov/library/publications/2011/compendia/usa-counties-2011.html

+

Table of contents

+ +
+

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 to smash it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • MetricWise
  • +
+
+ +
+

Maintainers

+

This module is maintained by the OCA.

+ +Odoo Community Association + +

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.

+

This module is part of the OCA/l10n-usa project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+
+ + diff --git a/l10n_us_crm_county/tests/__init__.py b/l10n_us_crm_county/tests/__init__.py new file mode 100644 index 00000000..abce0675 --- /dev/null +++ b/l10n_us_crm_county/tests/__init__.py @@ -0,0 +1 @@ +from . import test_crm_lead diff --git a/l10n_us_crm_county/tests/test_crm_lead.py b/l10n_us_crm_county/tests/test_crm_lead.py new file mode 100644 index 00000000..75a760e9 --- /dev/null +++ b/l10n_us_crm_county/tests/test_crm_lead.py @@ -0,0 +1,52 @@ +from odoo.tests import TransactionCase + + +class TestCrmLead(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.state_us = cls.env.ref("base.state_us_5") + + cls.county = cls.env["res.country.state.county"].create( + { + "name": "Test County", + "state_id": cls.state_us.id, + } + ) + + cls.partner = cls.env["res.partner"].create( + { + "name": "Test Partner", + "country_id": cls.env.ref("base.us").id, + "state_id": cls.state_us.id, + } + ) + + def test_compute_partner_address_values(self): + lead = self.env["crm.lead"].create( + { + "name": "Test Lead", + } + ) + self.assertFalse(lead.county_id) + self.partner.county_id = self.county.id + lead.partner_id = self.partner + self.assertEqual( + lead.county_id, + self.partner.county_id, + "should have updated lead with partner county", + ) + + def test_create_customer(self): + lead = self.env["crm.lead"].create( + { + "name": "Test Lead", + "county_id": self.county.id, + } + ) + customer = lead._create_customer() + self.assertEqual( + customer.county_id, + lead.county_id, + "should have created partner with lead county", + ) diff --git a/l10n_us_crm_county/views/crm_lead_views.xml b/l10n_us_crm_county/views/crm_lead_views.xml new file mode 100644 index 00000000..881a8360 --- /dev/null +++ b/l10n_us_crm_county/views/crm_lead_views.xml @@ -0,0 +1,41 @@ + + + + crm.lead + + + + + + + + + + + + + crm.lead + + + + + + + + + + crm.lead + + + + + + + + diff --git a/test-requirements.txt b/test-requirements.txt new file mode 100644 index 00000000..2e183723 --- /dev/null +++ b/test-requirements.txt @@ -0,0 +1,2 @@ +# DO NOT MERGE — temporary pin until OCA/l10n-usa#174 lands. +odoo-addon-l10n_us_base_county @ git+https://github.com/OCA/l10n-usa.git@refs/pull/174/head#subdirectory=l10n_us_base_county