From fd475243a6ec865c38fe5214ddda54aa44d341a0 Mon Sep 17 00:00:00 2001 From: Simone Orsi Date: Mon, 3 Oct 2022 11:15:57 +0200 Subject: [PATCH 1/2] purchaser_order_ubl: add TODO for tests --- purchase_order_ubl/tests/test_ubl_generate.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/purchase_order_ubl/tests/test_ubl_generate.py b/purchase_order_ubl/tests/test_ubl_generate.py index 693a5494a3..15b0681813 100644 --- a/purchase_order_ubl/tests/test_ubl_generate.py +++ b/purchase_order_ubl/tests/test_ubl_generate.py @@ -25,3 +25,5 @@ def test_ubl_generate(self): elif order.state in rfq_states: filename = order.get_ubl_filename("rfq", version=version) self.assertTrue(filename in res) + + # TODO: add tests to validate UBL data generation! From f10b3aaf9bca0a9bc082f5a5697278e54604bfbe Mon Sep 17 00:00:00 2001 From: Simone Orsi Date: Mon, 3 Oct 2022 11:17:22 +0200 Subject: [PATCH 2/2] Add edi_purchase_ubl_oca --- edi_purchase_ubl_oca/README.rst | 1 + edi_purchase_ubl_oca/__init__.py | 1 + edi_purchase_ubl_oca/__manifest__.py | 18 +++++++++++++ edi_purchase_ubl_oca/components/__init__.py | 1 + edi_purchase_ubl_oca/components/generate.py | 27 +++++++++++++++++++ .../demo/edi_exchange_type.xml | 20 ++++++++++++++ edi_purchase_ubl_oca/readme/CONFIGURATION.rst | 7 +++++ edi_purchase_ubl_oca/readme/CONTRIBUTORS.rst | 1 + edi_purchase_ubl_oca/readme/DESCRIPTION.rst | 5 ++++ .../odoo/addons/edi_purchase_ubl_oca | 1 + setup/edi_purchase_ubl_oca/setup.py | 6 +++++ 11 files changed, 88 insertions(+) create mode 100644 edi_purchase_ubl_oca/README.rst create mode 100644 edi_purchase_ubl_oca/__init__.py create mode 100644 edi_purchase_ubl_oca/__manifest__.py create mode 100644 edi_purchase_ubl_oca/components/__init__.py create mode 100644 edi_purchase_ubl_oca/components/generate.py create mode 100644 edi_purchase_ubl_oca/demo/edi_exchange_type.xml create mode 100644 edi_purchase_ubl_oca/readme/CONFIGURATION.rst create mode 100644 edi_purchase_ubl_oca/readme/CONTRIBUTORS.rst create mode 100644 edi_purchase_ubl_oca/readme/DESCRIPTION.rst create mode 120000 setup/edi_purchase_ubl_oca/odoo/addons/edi_purchase_ubl_oca create mode 100644 setup/edi_purchase_ubl_oca/setup.py diff --git a/edi_purchase_ubl_oca/README.rst b/edi_purchase_ubl_oca/README.rst new file mode 100644 index 0000000000..a74415d005 --- /dev/null +++ b/edi_purchase_ubl_oca/README.rst @@ -0,0 +1 @@ +wait for the bot diff --git a/edi_purchase_ubl_oca/__init__.py b/edi_purchase_ubl_oca/__init__.py new file mode 100644 index 0000000000..1377f57f5a --- /dev/null +++ b/edi_purchase_ubl_oca/__init__.py @@ -0,0 +1 @@ +from . import components diff --git a/edi_purchase_ubl_oca/__manifest__.py b/edi_purchase_ubl_oca/__manifest__.py new file mode 100644 index 0000000000..c24b935f72 --- /dev/null +++ b/edi_purchase_ubl_oca/__manifest__.py @@ -0,0 +1,18 @@ +# Copyright 2021 Camptocamp SA +# @author: Simone Orsi +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "EDI UBL Purchase", + "summary": """Handle inbound / outbound exchanges for purchases.""", + "version": "14.0.1.0.0", + "development_status": "Alpha", + "license": "AGPL-3", + "website": "https://github.com/OCA/edi", + "author": "Camptocamp, Odoo Community Association (OCA)", + "maintainers": ["simahawk"], + "depends": ["edi_oca", "edi_ubl_oca", "purchase_order_ubl"], + "demo": [ + "demo/edi_exchange_type.xml", + ], +} diff --git a/edi_purchase_ubl_oca/components/__init__.py b/edi_purchase_ubl_oca/components/__init__.py new file mode 100644 index 0000000000..f839b0d3b3 --- /dev/null +++ b/edi_purchase_ubl_oca/components/__init__.py @@ -0,0 +1 @@ +from . import generate diff --git a/edi_purchase_ubl_oca/components/generate.py b/edi_purchase_ubl_oca/components/generate.py new file mode 100644 index 0000000000..557344312d --- /dev/null +++ b/edi_purchase_ubl_oca/components/generate.py @@ -0,0 +1,27 @@ +# Copyright 2021 Camptocamp SA +# @author: Simone Orsi +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + + +from odoo.addons.component.core import Component + + +class EDIExchangePOGenerate(Component): + """Generate purchase orders.""" + + _name = "edi.output.ubl.purchase.order" + _inherit = "edi.component.output.mixin" + _usage = "output.generate.purchase.order" + + def generate(self): + return self._generate_ubl_xml() + + # TODO: add tests + def _generate_ubl_xml(self): + order = self.record + doc_type = order.get_ubl_purchase_order_doc_type() + if not doc_type: + raise NotImplementedError("TODO: handle no doc type") + version = order.get_ubl_version() + xml_string = order.generate_ubl_xml_string(doc_type, version=version) + return xml_string diff --git a/edi_purchase_ubl_oca/demo/edi_exchange_type.xml b/edi_purchase_ubl_oca/demo/edi_exchange_type.xml new file mode 100644 index 0000000000..d86e688ff6 --- /dev/null +++ b/edi_purchase_ubl_oca/demo/edi_exchange_type.xml @@ -0,0 +1,20 @@ + + + + + UBL PO out + UBL_PO_out + output + {record_name}-{type.code}-{dt} + xml + + +components: + generate: + usage: output.generate.purchase.order + + + diff --git a/edi_purchase_ubl_oca/readme/CONFIGURATION.rst b/edi_purchase_ubl_oca/readme/CONFIGURATION.rst new file mode 100644 index 0000000000..df94d54c51 --- /dev/null +++ b/edi_purchase_ubl_oca/readme/CONFIGURATION.rst @@ -0,0 +1,7 @@ +On your exchange type configured for UBL outbound exchanges use this conf in `advanced_settings_edit`:: + + components: + generate: + usage: output.generate.purchase.order + +That's it. diff --git a/edi_purchase_ubl_oca/readme/CONTRIBUTORS.rst b/edi_purchase_ubl_oca/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000000..f1c71bce18 --- /dev/null +++ b/edi_purchase_ubl_oca/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Simone Orsi diff --git a/edi_purchase_ubl_oca/readme/DESCRIPTION.rst b/edi_purchase_ubl_oca/readme/DESCRIPTION.rst new file mode 100644 index 0000000000..41f35c7a49 --- /dev/null +++ b/edi_purchase_ubl_oca/readme/DESCRIPTION.rst @@ -0,0 +1,5 @@ +Handle purchase exchanges with the EDI framework. + +This module is mostly a glue module for `purchase_order_ubl` with `edi_oca`. + +Allows you to generate and send purchase orders as UBL XML files. diff --git a/setup/edi_purchase_ubl_oca/odoo/addons/edi_purchase_ubl_oca b/setup/edi_purchase_ubl_oca/odoo/addons/edi_purchase_ubl_oca new file mode 120000 index 0000000000..4441505cb4 --- /dev/null +++ b/setup/edi_purchase_ubl_oca/odoo/addons/edi_purchase_ubl_oca @@ -0,0 +1 @@ +../../../../edi_purchase_ubl_oca \ No newline at end of file diff --git a/setup/edi_purchase_ubl_oca/setup.py b/setup/edi_purchase_ubl_oca/setup.py new file mode 100644 index 0000000000..28c57bb640 --- /dev/null +++ b/setup/edi_purchase_ubl_oca/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)