Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
8354593
[ADD] edi_webservice
etobella Dec 10, 2020
8d19e32
[UPD] Update edi_webservice.pot
oca-travis Mar 15, 2021
1df5b84
[UPD] README.rst
OCA-git-bot Mar 15, 2021
29ab94c
[MIG] edi_webservice_oca: Migration to 14.0
etobella May 14, 2021
9526be8
[UPD] Update edi_webservice_oca.pot
oca-travis May 26, 2021
398d68e
[UPD] README.rst
OCA-git-bot May 26, 2021
d8374f1
edi: improve backend view extension
simahawk Sep 17, 2021
30c879b
edi_webservice_oca: add missing page label
simahawk Oct 13, 2021
3d75d43
[UPD] Update edi_webservice_oca.pot
oca-travis Oct 13, 2021
dda8b0c
edi_webservice_oca 14.0.1.1.0
OCA-git-bot Oct 13, 2021
470bd3a
[MIG] edi_service_oca: Migration to 15.0
pedroguirao Feb 28, 2022
40bbb1b
[UPD] Update edi_webservice_oca.pot
Mar 1, 2022
68060e8
[UPD] README.rst
OCA-git-bot Mar 1, 2022
911e9a6
[IMP] edi_webservice: Promote to Beta
pedrobaeza Mar 3, 2022
c386e63
edi_webservice_oca 15.0.1.1.0
OCA-git-bot Mar 9, 2022
35faf43
[UPD] README.rst
OCA-git-bot Sep 3, 2023
5db0966
edi_webservice: fix tests setup
simahawk Sep 12, 2023
a6e9fdd
edi_webservice_oca 15.0.1.1.1
OCA-git-bot Sep 12, 2023
56af480
[UPD] README.rst
OCA-git-bot Sep 12, 2023
d7c319e
[IMP] edi_webservice_oca: pre-commit stuff
EvaSForgeFlow Jul 10, 2023
1603e22
[MIG] edi_webservice_oca: Migration to 16.0
EvaSForgeFlow Jul 10, 2023
2751451
[UPD] Update edi_webservice_oca.pot
Nov 9, 2023
f90e637
edi_webservice: add generic send component
simahawk Aug 26, 2022
622bfa6
edi_webservice: allow to send bytes
simahawk Oct 3, 2022
c6544ed
edi_webservice_oca: Adapt to 15.0
etobella Sep 15, 2023
0790014
rename documentation file
gurneyalex Feb 28, 2024
7575e3d
[UPD] Update edi_webservice_oca.pot
Mar 5, 2024
d419b48
[BOT] post-merge updates
OCA-git-bot Mar 5, 2024
9a973ac
Added translation using Weblate (Italian)
mymage May 13, 2024
398f3bc
Translated using Weblate (Italian)
mymage May 13, 2024
ca66533
[IMP] edi_webservice_oca: pre-commit stuff
JordiMForgeFlow Oct 24, 2024
686de0a
[MIG] edi_webservice_oca: Migration to V18
JordiMForgeFlow Oct 24, 2024
7c46e53
[UPD] Update edi_webservice_oca.pot
Mar 18, 2025
0787e9c
[BOT] post-merge updates
OCA-git-bot Mar 18, 2025
142f28b
[IMP] edi_webservice_oca: Adapt to new edi_core_oca logic
etobella Aug 29, 2025
0273f95
[BOT] post-merge updates
OCA-git-bot Sep 29, 2025
a44f48c
edi_webservice_oca: fix component lookup permission
simahawk Oct 14, 2025
19d2cec
edi_webservice_oca: add unit test for avg user lookup
simahawk Nov 26, 2025
c1d312c
[BOT] post-merge updates
OCA-git-bot Nov 27, 2025
071481a
[IMP] edi_webservice_oca: pre-commit auto fixes
AaronHForgeFlow Feb 4, 2026
201b662
[MIG] edi_webservice_oca
AaronHForgeFlow Feb 4, 2026
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
137 changes: 137 additions & 0 deletions edi_webservice_oca/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
.. image:: https://odoo-community.org/readme-banner-image
:target: https://odoo-community.org/get-involved?utm_source=readme
:alt: Odoo Community Association

==============
EDI WebService
==============

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:53a13902ac3279b551922ef5e3577b1cebf49ef7b9eca8bed55ee901b04b50d2
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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--framework-lightgray.png?logo=github
:target: https://github.com/OCA/edi-framework/tree/19.0/edi_webservice_oca
:alt: OCA/edi-framework
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/edi-framework-19-0/edi-framework-19-0-edi_webservice_oca
: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-framework&target_branch=19.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

Plug webservice module within EDI framework. Allows to configure attach
webservices on an EDI backend and/or on an exchange type.

**Table of contents**

.. contents::
:local:

Configuration
=============

Go to "EDI -> Config -> Backends" and edit or create one. Find the tab
"Webservice" and add a webservice. On the webservice record you can
specify all the general parameters to connect to the service (see
webservice README for more details).

If you want to take full control on if/how the webservice is used you
can do it via exchange type's advanced settings.

Hence, assuming your webservice has a URL configured as
\`\ https://my.endpoint/%7Bpath%7D\ \`:

::

components:
send:
usage: webservice.send # or any custom component usage inheriting from this
work_ctx:
webservice:
method: post # mandatory
url_params:
path: endpoint1/foo

For each call related to this type, you'll get a POST request against
https://my.endpoint/endpoint/foo.

``url_params`` can contain all the keys need for URL interpolation.

In addition, you can user ``url`` to override the full url used for the
call per exchange type.

If you want to send data as bytes you can use the option send_as_bytes
like:

::

[...]
webservice:
send_as_bytes: true
[...]

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/edi-framework/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/edi-framework/issues/new?body=module:%20edi_webservice_oca%0Aversion:%2019.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
-------

* Dixmit
* Camptocamp

Contributors
------------

- Enric Tobella <etobella@creublanca.es>
- Simone Orsi <simone.orsi@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-etobella| image:: https://github.com/etobella.png?size=40px
:target: https://github.com/etobella
:alt: etobella
.. |maintainer-simahawk| image:: https://github.com/simahawk.png?size=40px
:target: https://github.com/simahawk
:alt: simahawk

Current `maintainers <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-etobella| |maintainer-simahawk|

This module is part of the `OCA/edi-framework <https://github.com/OCA/edi-framework/tree/19.0/edi_webservice_oca>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 2 additions & 0 deletions edi_webservice_oca/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import components
from . import models
17 changes: 17 additions & 0 deletions edi_webservice_oca/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2020 Dixmit
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "EDI WebService",
"summary": """
Defines webservice integration from EDI Exchange records""",
"version": "19.0.1.0.0",
"license": "AGPL-3",
"development_status": "Beta",
"author": "Dixmit, Camptocamp, Odoo Community Association (OCA)",
"maintainers": ["etobella", "simahawk"],
"website": "https://github.com/OCA/edi-framework",
"depends": ["edi_component_oca", "webservice"],
"data": ["views/edi_backend.xml", "security/ir.model.access.csv"],
"demo": ["demo/edi_backend.xml"],
}
1 change: 1 addition & 0 deletions edi_webservice_oca/components/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import send
48 changes: 48 additions & 0 deletions edi_webservice_oca/components/send.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Copyright 2022 Camptocamp SA
# @author: Simone Orsi <simahawk@gmail.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import _, exceptions

from odoo.addons.component.core import Component


class EDIWebserviceSend(Component):
"""Generic component for webservice requests.

Configuration is expected to come from the work ctx key `webservice`.
You can easily pass via exchange type advanced settings.
"""

_name = "edi.webservice.send"
_inherit = [
"edi.component.mixin",
]
_usage = "webservice.send"

def __init__(self, work_context):
super().__init__(work_context)
self.ws_settings = getattr(work_context, "webservice", {})
self.webservice_backend = self.backend.webservice_backend_id

def send(self):
method, pargs, kwargs = self._get_call_params()
return self.webservice_backend.call(method, *pargs, **kwargs)

def _get_call_params(self):
try:
method = self.ws_settings["method"].lower()
except KeyError as err:
raise exceptions.UserError(
_("`method` is required in `webservice` type settings.")
) from err
pargs = self.ws_settings.get("pargs", [])
kwargs = self.ws_settings.get("kwargs", {})
kwargs["data"] = self._get_data()
return method, pargs, kwargs

def _get_data(self):
# By sending as bytes `requests` won't try to guess and/or alter the encoding.
# TODO: add tests
as_bytes = self.ws_settings.get("send_as_bytes")
return self.exchange_record._get_file_content(as_bytes=as_bytes)
20 changes: 20 additions & 0 deletions edi_webservice_oca/demo/edi_backend.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="demo_ws_backend" model="webservice.backend">
<field name="name">Demo backend</field>
<field name="tech_name">edi_demo_ws</field>
<field name="protocol">http</field>
<field name="url">https://foo.test/{endpoint}</field>
<field name="content_type">application/xml</field>
<field name="auth_type">none</field>
</record>
<record id="demo_edi_backend_type" model="edi.backend.type">
<field name="name">Demo backend type WS</field>
<field name="code">demo_ws_backend</field>
</record>
<record id="demo_edi_backend" model="edi.backend">
<field name="name">Demo backend w/ WS</field>
<field name="backend_type_id" ref="demo_edi_backend_type" />
<field name="webservice_backend_id" ref="demo_ws_backend" />
</record>
</odoo>
24 changes: 24 additions & 0 deletions edi_webservice_oca/i18n/edi_webservice.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# 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:ir.model.fields,field_description:edi_webservice.field_edi_backend__webservice_backend_id
msgid "Webservice Backend"
msgstr ""
35 changes: 35 additions & 0 deletions edi_webservice_oca/i18n/edi_webservice_oca.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * edi_webservice_oca
#
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: edi_webservice_oca
#: model:ir.model,name:edi_webservice_oca.model_edi_backend
msgid "EDI Backend"
msgstr ""

#. module: edi_webservice_oca
#: model_terms:ir.ui.view,arch_db:edi_webservice_oca.edi_backend_view_form
msgid "Webservice"
msgstr ""

#. module: edi_webservice_oca
#: model:ir.model.fields,field_description:edi_webservice_oca.field_edi_backend__webservice_backend_id
msgid "Webservice Backend"
msgstr ""

#. module: edi_webservice_oca
#. odoo-python
#: code:addons/edi_webservice_oca/components/send.py:0
msgid "`method` is required in `webservice` type settings."
msgstr ""
39 changes: 39 additions & 0 deletions edi_webservice_oca/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * edi_webservice_oca
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2024-05-13 12:34+0000\n"
"Last-Translator: mymage <stefano.consolaro@mymage.it>\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 4.17\n"

#. module: edi_webservice_oca
#: model:ir.model,name:edi_webservice_oca.model_edi_backend
msgid "EDI Backend"
msgstr "Backend EDI"

#. module: edi_webservice_oca
#: model_terms:ir.ui.view,arch_db:edi_webservice_oca.edi_backend_view_form
msgid "Webservice"
msgstr "Servizio web"

#. module: edi_webservice_oca
#: model:ir.model.fields,field_description:edi_webservice_oca.field_edi_backend__webservice_backend_id
msgid "Webservice Backend"
msgstr "Backend servizio web"

#. module: edi_webservice_oca
#. odoo-python
#: code:addons/edi_webservice_oca/components/send.py:0
#, python-format
msgid "`method` is required in `webservice` type settings."
msgstr "`method` è richiesto nelle impostazioni tipo `webservice`."
1 change: 1 addition & 0 deletions edi_webservice_oca/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import edi_backend
37 changes: 37 additions & 0 deletions edi_webservice_oca/models/edi_backend.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Copyright 2020 Dixmit
# 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)
ws_backend = self.webservice_backend_id.sudo()
if not ws_backend or key not in self._webservice_actions:
return candidates
return [f"webservice.{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)
ws_backend = self.webservice_backend_id.sudo()
if not ws_backend or key not in self._webservice_actions:
return res
res["webservice_protocol"] = ws_backend.protocol
return res

def _component_sort_key(self, component_class):
res = super()._component_sort_key(component_class)
ws_backend = self.webservice_backend_id
# Override to give precedence by `webservice_protocol` when needed.
if not ws_backend:
return res
return (
1 if getattr(component_class, "_webservice_protocol", False) else 0,
) + res
3 changes: 3 additions & 0 deletions edi_webservice_oca/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
Loading
Loading