diff --git a/edi_webservice/README.rst b/edi_webservice/README.rst new file mode 100644 index 0000000000..58d3ec8718 --- /dev/null +++ b/edi_webservice/README.rst @@ -0,0 +1,76 @@ +============== +Edi WebService +============== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:5c5d9632de1c9ab479b27c83367b2430f90bffc72a7ef196f6b0286c7ae59d2d + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Fedi-lightgray.png?logo=github + :target: https://github.com/OCA/edi/tree/13.0/edi_webservice + :alt: OCA/edi +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/edi-13-0/edi-13-0-edi_webservice + :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=13.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module creates WebService frameworks to be used on EDI + +**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 +~~~~~~~ + +* Creu Blanca + +Contributors +~~~~~~~~~~~~ + +* Enric Tobella + +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/edi_webservice/__init__.py b/edi_webservice/__init__.py new file mode 100644 index 0000000000..0650744f6b --- /dev/null +++ b/edi_webservice/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/edi_webservice/__manifest__.py b/edi_webservice/__manifest__.py new file mode 100644 index 0000000000..a8cba3f3b5 --- /dev/null +++ b/edi_webservice/__manifest__.py @@ -0,0 +1,15 @@ +# Copyright 2020 Creu Blanca +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Edi WebService", + "summary": """ + Defines webservice integration from EDI Exchange records""", + "version": "12.0.1.0.0", + "license": "AGPL-3", + "development_status": "Beta", + "author": "Creu Blanca,Odoo Community Association (OCA)", + "website": "https://github.com/OCA/edi", + "depends": ["edi_oca", "webservice"], + "data": ["views/edi_backend.xml", "security/ir.model.access.csv"], +} diff --git a/edi_webservice/i18n/edi_webservice.pot b/edi_webservice/i18n/edi_webservice.pot new file mode 100644 index 0000000000..ffaa2227f1 --- /dev/null +++ b/edi_webservice/i18n/edi_webservice.pot @@ -0,0 +1,29 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * edi_webservice +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 13.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: edi_webservice +#: model:ir.model,name:edi_webservice.model_edi_backend +msgid "EDI Backend" +msgstr "" + +#. module: edi_webservice +#: model_terms:ir.ui.view,arch_db:edi_webservice.edi_backend_view_form +msgid "Webservice" +msgstr "" + +#. module: edi_webservice +#: model:ir.model.fields,field_description:edi_webservice.field_edi_backend__webservice_backend_id +msgid "Webservice Backend" +msgstr "" diff --git a/edi_webservice/models/__init__.py b/edi_webservice/models/__init__.py new file mode 100644 index 0000000000..4b2c54ac39 --- /dev/null +++ b/edi_webservice/models/__init__.py @@ -0,0 +1 @@ +from . import edi_backend diff --git a/edi_webservice/models/edi_backend.py b/edi_webservice/models/edi_backend.py new file mode 100644 index 0000000000..48cc80b4ca --- /dev/null +++ b/edi_webservice/models/edi_backend.py @@ -0,0 +1,35 @@ +# Copyright 2020 Creu Blanca +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class EdiBackend(models.Model): + + _inherit = "edi.backend" + + webservice_backend_id = fields.Many2one("webservice.backend") + _webservice_actions = ("send", "receive") + + def _get_component_usage_candidates(self, exchange_record, key): + candidates = super()._get_component_usage_candidates(exchange_record, key) + if not self.webservice_backend_id or key not in self._webservice_actions: + return candidates + return ["webservice.{}".format(key)] + candidates + + def _component_match_attrs(self, exchange_record, key): + # Override to inject `webservice_protocol` as match attribute + res = super()._component_match_attrs(exchange_record, key) + if not self.webservice_backend_id or key not in self._webservice_actions: + return res + res["webservice_protocol"] = self.webservice_backend_id.protocol + return res + + def _component_sort_key(self, component_class): + res = super()._component_sort_key(component_class) + # Override to give precedence by `webservice_protocol` when needed. + if not self.webservice_backend_id: + return res + return ( + 1 if getattr(component_class, "_webservice_protocol", False) else 0, + ) + res diff --git a/edi_webservice/readme/CONTRIBUTORS.rst b/edi_webservice/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000000..93ec993e04 --- /dev/null +++ b/edi_webservice/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Enric Tobella diff --git a/edi_webservice/readme/DESCRIPTION.rst b/edi_webservice/readme/DESCRIPTION.rst new file mode 100644 index 0000000000..1e5684504d --- /dev/null +++ b/edi_webservice/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +This module creates WebService frameworks to be used on EDI diff --git a/edi_webservice/security/ir.model.access.csv b/edi_webservice/security/ir.model.access.csv new file mode 100644 index 0000000000..f9de375ff5 --- /dev/null +++ b/edi_webservice/security/ir.model.access.csv @@ -0,0 +1,3 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_webservice_backend_edi_manager,webservice_backend edi manager,webservice.model_webservice_backend,base_edi.group_edi_manager,1,1,1,1 +access_webservice_backend_user,webservice_backend user,webservice.model_webservice_backend,base.group_user,1,0,0,0 diff --git a/edi_webservice/static/description/icon.png b/edi_webservice/static/description/icon.png new file mode 100644 index 0000000000..3a0328b516 Binary files /dev/null and b/edi_webservice/static/description/icon.png differ diff --git a/edi_webservice/static/description/index.html b/edi_webservice/static/description/index.html new file mode 100644 index 0000000000..b57149eb3b --- /dev/null +++ b/edi_webservice/static/description/index.html @@ -0,0 +1,421 @@ + + + + + + +Edi WebService + + + +
+

Edi WebService

+ + +

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

+

This module creates WebService frameworks to be used on EDI

+

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

+
    +
  • Creu Blanca
  • +
+
+
+

Contributors

+ +
+
+

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/edi_webservice/tests/__init__.py b/edi_webservice/tests/__init__.py new file mode 100644 index 0000000000..835710e449 --- /dev/null +++ b/edi_webservice/tests/__init__.py @@ -0,0 +1 @@ +from . import test_edi_webservice diff --git a/edi_webservice/tests/test_edi_webservice.py b/edi_webservice/tests/test_edi_webservice.py new file mode 100644 index 0000000000..9c144f3349 --- /dev/null +++ b/edi_webservice/tests/test_edi_webservice.py @@ -0,0 +1,34 @@ +# Copyright 2020 Creu Blanca +# @author: Enric Tobella +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo.addons.edi_oca.tests.common import EDIBackendCommonTestCase + + +class TestEdiWebService(EDIBackendCommonTestCase): + @classmethod + def _setup_records(cls): + super()._setup_records() + cls.webservice = cls.env["webservice.backend"].create( + { + "name": "WebService", + "protocol": "http", + "url": "http://localhost.demo.odoo/", + "content_type": "application/xml", + "tech_name": "demo_ws", + } + ) + vals = { + "model": cls.partner._name, + "res_id": cls.partner.id, + } + cls.record = cls.backend.create_record("test_csv_input", vals) + + def test_components_with_ws(self): + self.backend.webservice_backend_id = self.webservice + components = self.backend._get_component_usage_candidates(self.record, "send") + self.assertIn("webservice.send", components) + + def test_components_without_ws(self): + components = self.backend._get_component_usage_candidates(self.record, "send") + self.assertNotIn("webservice.send", components) diff --git a/edi_webservice/views/edi_backend.xml b/edi_webservice/views/edi_backend.xml new file mode 100644 index 0000000000..da0435943f --- /dev/null +++ b/edi_webservice/views/edi_backend.xml @@ -0,0 +1,18 @@ + + + + + edi.backend + + + + + + + + + + + + diff --git a/setup/edi_webservice/odoo/addons/edi_webservice b/setup/edi_webservice/odoo/addons/edi_webservice new file mode 120000 index 0000000000..ab4aa0c883 --- /dev/null +++ b/setup/edi_webservice/odoo/addons/edi_webservice @@ -0,0 +1 @@ +../../../../edi_webservice \ No newline at end of file diff --git a/setup/edi_webservice/setup.py b/setup/edi_webservice/setup.py new file mode 100644 index 0000000000..28c57bb640 --- /dev/null +++ b/setup/edi_webservice/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)