-
-
Notifications
You must be signed in to change notification settings - Fork 818
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by JordiBForgeFlow
- Loading branch information
Showing
15 changed files
with
771 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
============ | ||
Partner DUNS | ||
============ | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:1da704e58803cbf2005b9430f6178b61e4de67b753f0ab115e73058988326441 | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |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%2Fpartner--contact-lightgray.png?logo=github | ||
:target: https://github.com/OCA/partner-contact/tree/14.0/partner_duns | ||
:alt: OCA/partner-contact | ||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
:target: https://translation.odoo-community.org/projects/partner-contact-14-0/partner-contact-14-0-partner_duns | ||
: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/partner-contact&target_branch=14.0 | ||
:alt: Try me on Runboat | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
This module let's you set a DUNS number on your contacts. | ||
|
||
**What's a DUNS Number?** | ||
|
||
The **The Data Universal Numbering System**, abbreviated as **DUNS** or **D-U-N-S**, is | ||
a proprietary system developed and managed by | ||
`Dun & Bradstreet (D&B) <https://www.dnb.com/duns-number.html>`_ | ||
that assigns a unique numeric identifier to a single business entity. | ||
|
||
It was introduced in 1963 to support D&B's credit reporting practice. It is standard | ||
worldwide. | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/partner-contact/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 <https://github.com/OCA/partner-contact/issues/new?body=module:%20partner_duns%0Aversion:%2014.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 | ||
~~~~~~~ | ||
|
||
* Camptocamp | ||
|
||
Contributors | ||
~~~~~~~~~~~~ | ||
|
||
* `Camptocamp <https://www.camptocamp.com>`_ | ||
|
||
* Iván Todorovich <ivan.todorovich@camptocamp.com> | ||
|
||
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. | ||
|
||
.. |maintainer-ivantodorovich| image:: https://github.com/ivantodorovich.png?size=40px | ||
:target: https://github.com/ivantodorovich | ||
:alt: ivantodorovich | ||
|
||
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__: | ||
|
||
|maintainer-ivantodorovich| | ||
|
||
This module is part of the `OCA/partner-contact <https://github.com/OCA/partner-contact/tree/14.0/partner_duns>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Copyright 2022 Camptocamp SA (https://www.camptocamp.com). | ||
# @author Iván Todorovich <ivan.todorovich@camptocamp.com> | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
{ | ||
"name": "Partner DUNS", | ||
"summary": "Set DUNS (Data Universal Numbering System) on partners", | ||
"version": "16.0.1.0.0", | ||
"author": "Camptocamp, Odoo Community Association (OCA)", | ||
"maintainers": ["ivantodorovich"], | ||
"website": "https://github.com/OCA/partner-contact", | ||
"license": "AGPL-3", | ||
"category": "Others", | ||
"depends": ["base"], | ||
"data": ["views/res_partner.xml"], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * partner_duns | ||
# | ||
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: partner_duns | ||
#: model_terms:ir.ui.view,arch_db:partner_duns.view_partner_form | ||
msgid "A partner with the same DUNS number already exists (" | ||
msgstr "" | ||
|
||
#. module: partner_duns | ||
#: model:ir.model,name:partner_duns.model_res_partner | ||
msgid "Contact" | ||
msgstr "" | ||
|
||
#. module: partner_duns | ||
#: model:ir.model.fields,field_description:partner_duns.field_res_partner__duns | ||
#: model:ir.model.fields,field_description:partner_duns.field_res_users__duns | ||
msgid "DUNS" | ||
msgstr "" | ||
|
||
#. module: partner_duns | ||
#: model:ir.model.fields,help:partner_duns.field_res_partner__duns | ||
#: model:ir.model.fields,help:partner_duns.field_res_users__duns | ||
msgid "Data Universal Numbering System" | ||
msgstr "" | ||
|
||
#. module: partner_duns | ||
#: model:ir.model.fields,field_description:partner_duns.field_res_partner__display_name | ||
msgid "Display Name" | ||
msgstr "" | ||
|
||
#. module: partner_duns | ||
#: model:ir.model.fields,field_description:partner_duns.field_res_partner__id | ||
msgid "ID" | ||
msgstr "" | ||
|
||
#. module: partner_duns | ||
#: model:ir.model.fields,field_description:partner_duns.field_res_partner____last_update | ||
msgid "Last Modified on" | ||
msgstr "" | ||
|
||
#. module: partner_duns | ||
#: model:ir.model.fields,field_description:partner_duns.field_res_partner__same_duns_partner_id | ||
#: model:ir.model.fields,field_description:partner_duns.field_res_users__same_duns_partner_id | ||
msgid "Partner with same DUNS" | ||
msgstr "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import res_partner |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# Copyright 2022 Camptocamp SA (https://www.camptocamp.com). | ||
# @author Iván Todorovich <ivan.todorovich@camptocamp.com> | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import api, fields, models | ||
|
||
|
||
class ResPartner(models.Model): | ||
_inherit = "res.partner" | ||
|
||
duns = fields.Char( | ||
string="DUNS", | ||
help="Data Universal Numbering System", | ||
copy=False, | ||
) | ||
same_duns_partner_id = fields.Many2one( | ||
comodel_name="res.partner", | ||
compute="_compute_same_duns_partner_id", | ||
string="Partner with same DUNS", | ||
) | ||
|
||
@api.depends("duns", "company_id") | ||
def _compute_same_duns_partner_id(self): | ||
for partner in self: | ||
if not partner.duns or partner.parent_id: | ||
partner.same_duns_partner_id = False | ||
continue | ||
# NOTE: use _origin to deal with onchange() | ||
partner_id = partner._origin.id | ||
domain = [ | ||
("duns", "=", partner.duns), | ||
("company_id", "in", [False, partner.company_id.id]), | ||
] | ||
if partner_id: | ||
domain += [ | ||
("id", "!=", partner_id), | ||
"!", | ||
("id", "child_of", partner_id), | ||
] | ||
# NOTE: active_test=False because if a partner has been deactivated you | ||
# still want to show the warning, so that you can reactivate it instead | ||
# of creating a new one, which would loose its history. | ||
Partner = self.with_context(active_test=False).sudo() | ||
partner.same_duns_partner_id = Partner.search(domain, limit=1) | ||
|
||
@api.model | ||
def _sanitize_duns(self, duns): | ||
return duns and "".join(filter(str.isdigit, duns)) | ||
|
||
@api.onchange("duns") | ||
def _onchange_duns(self): | ||
for rec in self: | ||
sanitized = rec._sanitize_duns(rec.duns) | ||
if rec.duns != sanitized: | ||
rec.duns = sanitized | ||
|
||
@api.model_create_multi | ||
def create(self, vals_list): | ||
for vals in vals_list: | ||
if "duns" in vals: | ||
vals["duns"] = self._sanitize_duns(vals["duns"]) | ||
return super().create(vals_list) | ||
|
||
def write(self, vals): | ||
if "duns" in vals: | ||
vals["duns"] = self._sanitize_duns(vals["duns"]) | ||
return super().write(vals) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
* `Camptocamp <https://www.camptocamp.com>`_ | ||
|
||
* Iván Todorovich <ivan.todorovich@camptocamp.com> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
This module let's you set a DUNS number on your contacts. | ||
|
||
**What's a DUNS Number?** | ||
|
||
The **The Data Universal Numbering System**, abbreviated as **DUNS** or **D-U-N-S**, is | ||
a proprietary system developed and managed by | ||
`Dun & Bradstreet (D&B) <https://www.dnb.com/duns-number.html>`_ | ||
that assigns a unique numeric identifier to a single business entity. | ||
|
||
It was introduced in 1963 to support D&B's credit reporting practice. It is standard | ||
worldwide. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.