diff --git a/l10n_us_partner_legal_number/README.rst b/l10n_us_partner_legal_number/README.rst new file mode 100644 index 00000000..a5f5db9a --- /dev/null +++ b/l10n_us_partner_legal_number/README.rst @@ -0,0 +1,84 @@ +======================================================== +Add Legal Number for North American Banking & Financials +======================================================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:0c77630412fcc3a3857fb1f6000d4dd0d5cfe95137c5068be138701cf02689ec + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fl10n--usa-lightgray.png?logo=github + :target: https://github.com/OCA/l10n-usa/tree/17.0/l10n_us_partner_legal_number + :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-17-0/l10n-usa-17-0-l10n_us_partner_legal_number + :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=17.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Add Legal Number for North American Banking & Financials + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +Add Legal Number Field + +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 +------- + +* Open Source Integrators + +Contributors +------------ + +- Chankya Soni +- Maxime Chambreuil +- Serpent Consulting Services Pvt. Ltd. +- Levent Karakas + +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_partner_legal_number/__init__.py b/l10n_us_partner_legal_number/__init__.py new file mode 100644 index 00000000..83e553ac --- /dev/null +++ b/l10n_us_partner_legal_number/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import models diff --git a/l10n_us_partner_legal_number/__manifest__.py b/l10n_us_partner_legal_number/__manifest__.py new file mode 100644 index 00000000..4370917b --- /dev/null +++ b/l10n_us_partner_legal_number/__manifest__.py @@ -0,0 +1,16 @@ +# Copyright 2021 Open Source Integrators +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +{ + "name": "Add Legal Number for North American Banking & Financials", + "summary": "Add Legal Number for North American Banking & Financials", + "version": "17.0.1.0.0", + "license": "AGPL-3", + "author": "Open Source Integrators, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/l10n-usa", + "category": "Banking addons", + "depends": ["account"], + "data": ["views/res_partner.xml"], + "installable": True, + "external_dependencies": {"python": ["python-stdnum"]}, +} diff --git a/l10n_us_partner_legal_number/i18n/l10n_us_partner_legal_number.pot b/l10n_us_partner_legal_number/i18n/l10n_us_partner_legal_number.pot new file mode 100644 index 00000000..6fe95296 --- /dev/null +++ b/l10n_us_partner_legal_number/i18n/l10n_us_partner_legal_number.pot @@ -0,0 +1,53 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * l10n_us_partner_legal_number +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.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_partner_legal_number +#. odoo-python +#: code:addons/l10n_us_partner_legal_number/models/base.py:0 +#, python-format +msgid "%s is not a valid EIN / SSN / Canadian Business Number" +msgstr "" + +#. module: l10n_us_partner_legal_number +#: model:ir.model,name:l10n_us_partner_legal_number.model_res_partner +msgid "Contact" +msgstr "" + +#. module: l10n_us_partner_legal_number +#: model:ir.model,name:l10n_us_partner_legal_number.model_countinghouse_legal_id_number +msgid "Counting House Legal Id Number" +msgstr "" + +#. module: l10n_us_partner_legal_number +#: model_terms:ir.ui.view,arch_db:l10n_us_partner_legal_number.view_partner_legal_id_number +msgid "EIN / SSN / BN" +msgstr "" + +#. module: l10n_us_partner_legal_number +#: model:ir.model.fields,help:l10n_us_partner_legal_number.field_countinghouse_legal_id_number__legal_id_number +#: model:ir.model.fields,help:l10n_us_partner_legal_number.field_res_partner__legal_id_number +#: model:ir.model.fields,help:l10n_us_partner_legal_number.field_res_users__legal_id_number +msgid "" +"For US entities, enter valid EIN or Social Security Number.\n" +" Canadian entities, enter Canadian Business Number.\n" +" " +msgstr "" + +#. module: l10n_us_partner_legal_number +#: model:ir.model.fields,field_description:l10n_us_partner_legal_number.field_countinghouse_legal_id_number__legal_id_number +#: model:ir.model.fields,field_description:l10n_us_partner_legal_number.field_res_partner__legal_id_number +#: model:ir.model.fields,field_description:l10n_us_partner_legal_number.field_res_users__legal_id_number +msgid "Legal ID" +msgstr "" diff --git a/l10n_us_partner_legal_number/models/__init__.py b/l10n_us_partner_legal_number/models/__init__.py new file mode 100644 index 00000000..5315c065 --- /dev/null +++ b/l10n_us_partner_legal_number/models/__init__.py @@ -0,0 +1,4 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import base +from . import res_partner diff --git a/l10n_us_partner_legal_number/models/base.py b/l10n_us_partner_legal_number/models/base.py new file mode 100644 index 00000000..0786a7c4 --- /dev/null +++ b/l10n_us_partner_legal_number/models/base.py @@ -0,0 +1,43 @@ +from stdnum.ca import bn +from stdnum.us import ein, ssn + +from odoo import _, api, fields, models +from odoo.exceptions import UserError + + +class LegalIDNumber(models.AbstractModel): + """ + Odoo's VAT field validation prevents it from being used + for EIN / GST / SSN, etc. + + Use generic ID and apply validation depending on the Country field. + """ + + _name = "countinghouse.legal_id_number" + _description = "Counting House Legal Id Number" + + legal_id_number = fields.Char( + string="Legal ID", + required=False, + help="""For US entities, enter valid EIN or Social Security Number. + Canadian entities, enter Canadian Business Number. + """, + ) + + @api.constrains("legal_id_number") + def validate_legal_id_number(self): + if not self.legal_id_number: + return + valid = False + for v in (ssn, ein, bn): + try: + v.validate(self.legal_id_number) + valid = True + break + except Exception: + continue + if not valid: + raise UserError( + _("%s is not a valid EIN / SSN / Canadian Business Number") + % self.legal_id_number + ) diff --git a/l10n_us_partner_legal_number/models/res_partner.py b/l10n_us_partner_legal_number/models/res_partner.py new file mode 100644 index 00000000..594c720d --- /dev/null +++ b/l10n_us_partner_legal_number/models/res_partner.py @@ -0,0 +1,6 @@ +from odoo import models + + +class ResPartner(models.Model): + _name = "res.partner" + _inherit = ["countinghouse.legal_id_number", "res.partner"] diff --git a/l10n_us_partner_legal_number/pyproject.toml b/l10n_us_partner_legal_number/pyproject.toml new file mode 100644 index 00000000..4231d0cc --- /dev/null +++ b/l10n_us_partner_legal_number/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/l10n_us_partner_legal_number/readme/CONTRIBUTORS.md b/l10n_us_partner_legal_number/readme/CONTRIBUTORS.md new file mode 100644 index 00000000..7fc73d9a --- /dev/null +++ b/l10n_us_partner_legal_number/readme/CONTRIBUTORS.md @@ -0,0 +1,4 @@ +- Chankya Soni \<\> +- Maxime Chambreuil \<\> +- Serpent Consulting Services Pvt. Ltd. \<\> +- Levent Karakas \<\> diff --git a/l10n_us_partner_legal_number/readme/DESCRIPTION.md b/l10n_us_partner_legal_number/readme/DESCRIPTION.md new file mode 100644 index 00000000..e1a2fc53 --- /dev/null +++ b/l10n_us_partner_legal_number/readme/DESCRIPTION.md @@ -0,0 +1 @@ +Add Legal Number for North American Banking & Financials diff --git a/l10n_us_partner_legal_number/readme/USAGE.md b/l10n_us_partner_legal_number/readme/USAGE.md new file mode 100644 index 00000000..b11b7ffa --- /dev/null +++ b/l10n_us_partner_legal_number/readme/USAGE.md @@ -0,0 +1 @@ +Add Legal Number Field diff --git a/l10n_us_partner_legal_number/static/description/icon.png b/l10n_us_partner_legal_number/static/description/icon.png new file mode 100644 index 00000000..3a0328b5 Binary files /dev/null and b/l10n_us_partner_legal_number/static/description/icon.png differ diff --git a/l10n_us_partner_legal_number/static/description/index.html b/l10n_us_partner_legal_number/static/description/index.html new file mode 100644 index 00000000..cfbe0de2 --- /dev/null +++ b/l10n_us_partner_legal_number/static/description/index.html @@ -0,0 +1,428 @@ + + + + + +Add Legal Number for North American Banking & Financials + + + + + + diff --git a/l10n_us_partner_legal_number/views/res_partner.xml b/l10n_us_partner_legal_number/views/res_partner.xml new file mode 100644 index 00000000..251faec0 --- /dev/null +++ b/l10n_us_partner_legal_number/views/res_partner.xml @@ -0,0 +1,13 @@ + + + + Partner Legal ID Number + res.partner + + + + + + + + diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000..f8f07db7 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +# generated from manifests external_dependencies +python-stdnum