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

[16.0] [MIG] l10n_us_partner_legal_number #93

Merged
merged 2 commits into from
Jun 20, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 81 additions & 0 deletions l10n_us_partner_legal_number/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
========================================================
Add Legal Number for North American Banking & Financials
========================================================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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/16.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-16-0/l10n-usa-16-0-l10n_us_partner_legal_number
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/203/16.0
:alt: Try me on Runbot

|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 <https://github.com/OCA/l10n-usa/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 <https://github.com/OCA/l10n-usa/issues/new?body=module:%20l10n_us_partner_legal_number%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

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

Credits
=======

Authors
~~~~~~~

* Open Source Integrators

Contributors
~~~~~~~~~~~~

* Chankya Soni <[email protected]>
* Maxime Chambreuil <[email protected]>
* Serpent Consulting Services Pvt. Ltd. <[email protected]>
* Levent Karakas <[email protected]>

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 <https://github.com/OCA/l10n-usa/tree/16.0/l10n_us_partner_legal_number>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
3 changes: 3 additions & 0 deletions l10n_us_partner_legal_number/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from . import models
16 changes: 16 additions & 0 deletions l10n_us_partner_legal_number/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2021 Open Source Integrators <[email protected]>
# 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": "16.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"]},
}
70 changes: 70 additions & 0 deletions l10n_us_partner_legal_number/i18n/l10n_us_partner_legal_number.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# 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 14.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
#: 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 "Countinghouse Legal Id Number"
msgstr ""

#. module: l10n_us_partner_legal_number
#: model:ir.model.fields,field_description:l10n_us_partner_legal_number.field_countinghouse_legal_id_number__display_name
#: model:ir.model.fields,field_description:l10n_us_partner_legal_number.field_res_partner__display_name
msgid "Display Name"
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__id
#: model:ir.model.fields,field_description:l10n_us_partner_legal_number.field_res_partner__id
msgid "ID"
msgstr ""

#. module: l10n_us_partner_legal_number
#: model:ir.model.fields,field_description:l10n_us_partner_legal_number.field_countinghouse_legal_id_number____last_update
#: model:ir.model.fields,field_description:l10n_us_partner_legal_number.field_res_partner____last_update
msgid "Last Modified on"
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 ""
4 changes: 4 additions & 0 deletions l10n_us_partner_legal_number/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from . import base
from . import res_partner
43 changes: 43 additions & 0 deletions l10n_us_partner_legal_number/models/base.py
Original file line number Diff line number Diff line change
@@ -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

Check warning on line 31 in l10n_us_partner_legal_number/models/base.py

View check run for this annotation

Codecov / codecov/patch

l10n_us_partner_legal_number/models/base.py#L30-L31

Added lines #L30 - L31 were not covered by tests
for v in (ssn, ein, bn):
try:
v.validate(self.legal_id_number)
valid = True
break
except Exception:
continue

Check warning on line 38 in l10n_us_partner_legal_number/models/base.py

View check run for this annotation

Codecov / codecov/patch

l10n_us_partner_legal_number/models/base.py#L33-L38

Added lines #L33 - L38 were not covered by tests
if not valid:
raise UserError(

Check warning on line 40 in l10n_us_partner_legal_number/models/base.py

View check run for this annotation

Codecov / codecov/patch

l10n_us_partner_legal_number/models/base.py#L40

Added line #L40 was not covered by tests
_("%s is not a valid EIN / SSN / Canadian Business Number")
% self.legal_id_number
)
6 changes: 6 additions & 0 deletions l10n_us_partner_legal_number/models/res_partner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from odoo import models


class ResPartner(models.Model):
_name = "res.partner"
_inherit = ["countinghouse.legal_id_number", "res.partner"]
4 changes: 4 additions & 0 deletions l10n_us_partner_legal_number/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
* Chankya Soni <[email protected]>
* Maxime Chambreuil <[email protected]>
* Serpent Consulting Services Pvt. Ltd. <[email protected]>
* Levent Karakas <[email protected]>
1 change: 1 addition & 0 deletions l10n_us_partner_legal_number/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add Legal Number for North American Banking & Financials
1 change: 1 addition & 0 deletions l10n_us_partner_legal_number/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add Legal Number Field
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading