diff --git a/partner_identification_import/README.rst b/partner_identification_import/README.rst new file mode 100644 index 0000000000..743108d9ef --- /dev/null +++ b/partner_identification_import/README.rst @@ -0,0 +1,95 @@ +.. image:: https://odoo-community.org/readme-banner-image + :target: https://odoo-community.org/get-involved?utm_source=readme + :alt: Odoo Community Association + +============================= +Partner Identification Import +============================= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:4bfd68c6b919e15048cf359cd28bb03fbc267eb6f47891289f708a933eff9db8 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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-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%2Fedi-lightgray.png?logo=github + :target: https://github.com/OCA/edi/tree/19.0/partner_identification_import + :alt: OCA/edi +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/edi-19-0/edi-19-0-partner_identification_import + :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/edi&target_branch=19.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Glue module between base_business_document_import and +partner_identification (in OCA/partner-contact) + +Allow to define extra partner ID (thanks to partner_identification) and +match the partner using for exemple the UBL PartyIdentification/ID + +**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 +------- + +* BCIM + +Contributors +------------ + +- Jacques-Etienne Baudoux + +Trobz + +- Dung Tran + +Other credits +------------- + +The development of this module has been financially supported by: + +- Camptocamp + +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/edi `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/partner_identification_import/__init__.py b/partner_identification_import/__init__.py new file mode 100644 index 0000000000..0650744f6b --- /dev/null +++ b/partner_identification_import/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/partner_identification_import/__manifest__.py b/partner_identification_import/__manifest__.py new file mode 100644 index 0000000000..94e885b35a --- /dev/null +++ b/partner_identification_import/__manifest__.py @@ -0,0 +1,17 @@ +# Copyright 2020 Jacques-Etienne Baudoux +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Partner Identification Import", + "version": "19.0.1.0.0", + "category": "Tools", + "license": "AGPL-3", + "summary": "Provides partner matching on extra ID", + "author": "BCIM, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/edi", + "depends": [ + "base_business_document_import", + # OCA/partner-contact + "partner_identification", + ], +} diff --git a/partner_identification_import/i18n/es.po b/partner_identification_import/i18n/es.po new file mode 100644 index 0000000000..6cc3725daa --- /dev/null +++ b/partner_identification_import/i18n/es.po @@ -0,0 +1,60 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * partner_identification_import +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-11-25 11:34+0000\n" +"Last-Translator: Ivorra78 \n" +"Language-Team: none\n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.17\n" + +#. module: partner_identification_import +#: model:ir.model,name:partner_identification_import.model_business_document_import +msgid "Common methods to import business documents" +msgstr "Métodos habituales para importar documentos comerciales" + +#. module: partner_identification_import +#: model:ir.model.fields,field_description:partner_identification_import.field_business_document_import__display_name +msgid "Display Name" +msgstr "Mostrar Nombre" + +#. module: partner_identification_import +#: model:ir.model.fields,field_description:partner_identification_import.field_business_document_import__id +msgid "ID" +msgstr "ID" + +#. module: partner_identification_import +#: code:addons/partner_identification_import/models/business_document_import.py:0 +#, python-format +msgid "" +"ID Number: {}\n" +"ID Number Category: {}\n" +"\n" +msgstr "" +"Número de identificación: {}\n" +"Categoría del número de identificación: {}\n" +"\n" + +#. module: partner_identification_import +#: model:ir.model.fields,field_description:partner_identification_import.field_business_document_import____last_update +msgid "Last Modified on" +msgstr "Última Modificación el" + +#. module: partner_identification_import +#: code:addons/partner_identification_import/models/business_document_import.py:0 +#, python-format +msgid "" +"Odoo couldn't find a partner corresponding to the following information extracted from the business document:\n" +"{}" +msgstr "" +"Odoo no pudo encontrar un socio correspondiente a la siguiente información " +"extraída del documento comercial:\n" +"{}" diff --git a/partner_identification_import/i18n/it.po b/partner_identification_import/i18n/it.po new file mode 100644 index 0000000000..d7fcce5095 --- /dev/null +++ b/partner_identification_import/i18n/it.po @@ -0,0 +1,60 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * partner_identification_import +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2025-06-17 06:39+0000\n" +"Last-Translator: mymage \n" +"Language-Team: none\n" +"Language: it\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 5.10.4\n" + +#. module: partner_identification_import +#: model:ir.model,name:partner_identification_import.model_business_document_import +msgid "Common methods to import business documents" +msgstr "Metodi comuni per l'importazione di documenti di lavoro" + +#. module: partner_identification_import +#: model:ir.model.fields,field_description:partner_identification_import.field_business_document_import__display_name +msgid "Display Name" +msgstr "Nome visualizzato" + +#. module: partner_identification_import +#: model:ir.model.fields,field_description:partner_identification_import.field_business_document_import__id +msgid "ID" +msgstr "ID" + +#. module: partner_identification_import +#: code:addons/partner_identification_import/models/business_document_import.py:0 +#, python-format +msgid "" +"ID Number: {}\n" +"ID Number Category: {}\n" +"\n" +msgstr "" +"Numero ID: {}\n" +"Numero ID categoria: {}\n" +"\n" + +#. module: partner_identification_import +#: model:ir.model.fields,field_description:partner_identification_import.field_business_document_import____last_update +msgid "Last Modified on" +msgstr "Ultima modifica il" + +#. module: partner_identification_import +#: code:addons/partner_identification_import/models/business_document_import.py:0 +#, python-format +msgid "" +"Odoo couldn't find a partner corresponding to the following information extracted from the business document:\n" +"{}" +msgstr "" +"Odoo non trova un partner che corrisponda alle seguenti informazioni " +"estratte dal documento commerciale\n" +"{}" diff --git a/partner_identification_import/i18n/partner_identification_import.pot b/partner_identification_import/i18n/partner_identification_import.pot new file mode 100644 index 0000000000..e878f55e18 --- /dev/null +++ b/partner_identification_import/i18n/partner_identification_import.pot @@ -0,0 +1,36 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * partner_identification_import +# +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: partner_identification_import +#: model:ir.model,name:partner_identification_import.model_business_document_import +msgid "Common methods to import business documents" +msgstr "" + +#. module: partner_identification_import +#. odoo-python +#: code:addons/partner_identification_import/models/business_document_import.py:0 +msgid "" +"ID Number: %(value)s\n" +"ID Number Category: %(schemeID)s\n" +"\n" +msgstr "" + +#. module: partner_identification_import +#. odoo-python +#: code:addons/partner_identification_import/models/business_document_import.py:0 +msgid "" +"Odoo couldn't find a partner corresponding to the following information extracted from the business document:\n" +"{}" +msgstr "" diff --git a/partner_identification_import/models/__init__.py b/partner_identification_import/models/__init__.py new file mode 100644 index 0000000000..d695bc5f59 --- /dev/null +++ b/partner_identification_import/models/__init__.py @@ -0,0 +1 @@ +from . import business_document_import diff --git a/partner_identification_import/models/business_document_import.py b/partner_identification_import/models/business_document_import.py new file mode 100644 index 0000000000..459acd2149 --- /dev/null +++ b/partner_identification_import/models/business_document_import.py @@ -0,0 +1,70 @@ +# Copyright 2020 Jacques-Etienne Baudoux +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import api, models +from odoo.fields import Domain + + +class BusinessDocumentImport(models.AbstractModel): + _inherit = "business.document.import" + + @api.model + def _hook_match_partner(self, partner_dict, chatter_msg, domain, order): + # Loop on all the partner_dict["id_number"] and search for a partner + # having one. If the schemeID matches an existing Id Number Category, + # then a match is required. + schemeIDs = [ + e["schemeID"] for e in partner_dict.get("id_number", []) if e["schemeID"] + ] + if schemeIDs: + schemes = self.env["res.partner.id_category"].search( + Domain("code", "in", schemeIDs) + ) + unmatched = [] + for ident in partner_dict.get("id_number", []): + if ident.get("schemeID") not in schemes.mapped("code"): + continue + categ = schemes.filtered(lambda s, _id=ident: s.code == _id["schemeID"]) + id_number = self.env["res.partner.id_number"].search( + Domain.AND( + [ + Domain("category_id", "in", categ.ids), + Domain("name", "=", ident["value"]), + Domain("status", "!=", "close"), + ] + ), + limit=1, + ) + if id_number: + partner = id_number.partner_id + # Search for a contact of this partner + domain = Domain.AND( + [ + Domain("parent_id", "=", partner.id), + Domain("is_company", "=", False), + ] + ) + contact = self._match_partner_contact( + partner_dict, chatter_msg, domain, order + ) + if contact: + return contact + return id_number.partner_id + unmatched.append( + self.env._( + "ID Number: %(value)s\nID Number Category: %(schemeID)s\n\n", + **ident, + ) + ) + if unmatched: + raise self.user_error_wrap( + "_hook_match_partner", + partner_dict, + self.env._( + "Odoo couldn't find a partner corresponding to the " + "following information extracted from the business document:\n" + "%(join_unmatched)s", + join_unmatched="or\n".join(unmatched), + ), + ) + return super()._hook_match_partner(partner_dict, chatter_msg, domain, order) diff --git a/partner_identification_import/pyproject.toml b/partner_identification_import/pyproject.toml new file mode 100644 index 0000000000..4231d0cccb --- /dev/null +++ b/partner_identification_import/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/partner_identification_import/readme/CONTRIBUTORS.md b/partner_identification_import/readme/CONTRIBUTORS.md new file mode 100644 index 0000000000..76e880a46d --- /dev/null +++ b/partner_identification_import/readme/CONTRIBUTORS.md @@ -0,0 +1,5 @@ +- Jacques-Etienne Baudoux \<\> + +Trobz + +- Dung Tran \<\> diff --git a/partner_identification_import/readme/CREDITS.md b/partner_identification_import/readme/CREDITS.md new file mode 100644 index 0000000000..705d3b30ca --- /dev/null +++ b/partner_identification_import/readme/CREDITS.md @@ -0,0 +1,3 @@ +The development of this module has been financially supported by: + +- Camptocamp diff --git a/partner_identification_import/readme/DESCRIPTION.md b/partner_identification_import/readme/DESCRIPTION.md new file mode 100644 index 0000000000..d5b2fe414e --- /dev/null +++ b/partner_identification_import/readme/DESCRIPTION.md @@ -0,0 +1,5 @@ +Glue module between base_business_document_import and +partner_identification (in OCA/partner-contact) + +Allow to define extra partner ID (thanks to partner_identification) and +match the partner using for exemple the UBL PartyIdentification/ID diff --git a/partner_identification_import/static/description/icon.png b/partner_identification_import/static/description/icon.png new file mode 100644 index 0000000000..3a0328b516 Binary files /dev/null and b/partner_identification_import/static/description/icon.png differ diff --git a/partner_identification_import/static/description/index.html b/partner_identification_import/static/description/index.html new file mode 100644 index 0000000000..211e353138 --- /dev/null +++ b/partner_identification_import/static/description/index.html @@ -0,0 +1,444 @@ + + + + + +README.rst + + + +
+ + + +Odoo Community Association + +
+

Partner Identification Import

+ +

Beta License: AGPL-3 OCA/edi Translate me on Weblate Try me on Runboat

+

Glue module between base_business_document_import and +partner_identification (in OCA/partner-contact)

+

Allow to define extra partner ID (thanks to partner_identification) and +match the partner using for exemple the UBL PartyIdentification/ID

+

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

+
    +
  • BCIM
  • +
+
+
+

Contributors

+ +

Trobz

+ +
+
+

Other credits

+

The development of this module has been financially supported by:

+
    +
  • Camptocamp
  • +
+
+
+

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/edi project on GitHub.

+

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

+
+
+
+
+ + diff --git a/partner_identification_import/tests/__init__.py b/partner_identification_import/tests/__init__.py new file mode 100644 index 0000000000..12d28211d4 --- /dev/null +++ b/partner_identification_import/tests/__init__.py @@ -0,0 +1 @@ +from . import test_business_document_import diff --git a/partner_identification_import/tests/test_business_document_import.py b/partner_identification_import/tests/test_business_document_import.py new file mode 100644 index 0000000000..3efa3fb979 --- /dev/null +++ b/partner_identification_import/tests/test_business_document_import.py @@ -0,0 +1,46 @@ +# Copyright 2020 Jacques-Etienne Baudoux +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from odoo.tests.common import TransactionCase + + +class TestBaseBusinessDocumentImport(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True)) + cls.bdio = cls.env["business.document.import"] + externalID = "MYEXTID" + externalSchemeID = "EXTCATEG" + cls.partner1 = cls.env["res.partner"].create({"name": "Extra ID"}) + categ = cls.env["res.partner.id_category"].create( + {"name": "Extra Categ", "code": externalSchemeID} + ) + cls.env["res.partner.id_number"].create( + { + "category_id": categ.id, + "name": externalID, + "partner_id": cls.partner1.id, + } + ) + cls.partner1_contact = cls.env["res.partner"].create( + {"name": "Contact", "parent_id": cls.partner1.id, "type": "contact"} + ) + cls.partner_dict = { + "id_number": [{"value": externalID, "schemeID": externalSchemeID}] + } + + def test_match_partner(self): + warn = [] + res = self.bdio._match_partner(self.partner_dict, warn, partner_type=False) + self.assertEqual(res, self.partner1) + + def test_match_partner_contact(self): + warn = [] + # Match contact + self.partner_dict["contact"] = "Contact" + res = self.bdio._match_partner(self.partner_dict, warn, partner_type=False) + self.assertEqual(res, self.partner1_contact) + # Match partner + self.partner_dict["contact"] = "Contact2" + res = self.bdio._match_partner(self.partner_dict, warn, partner_type=False) + self.assertEqual(res, self.partner1)