Skip to content

[12.0][ADD] webservice_soap #97

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: 12.0
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ on:

jobs:
pre-commit:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.6"
python-version: "3.6.15"
- name: Get python version
run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV
- uses: actions/cache@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
fi
done
test:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
container: ${{ matrix.container }}
name: ${{ matrix.name }}
strategy:
Expand Down
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# generated from manifests external_dependencies
zeep
1 change: 1 addition & 0 deletions setup/webservice_soap/odoo/addons/webservice_soap
6 changes: 6 additions & 0 deletions setup/webservice_soap/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
77 changes: 77 additions & 0 deletions webservice_soap/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
===============
Webservice SOAP
===============

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

.. |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%2Fweb--api-lightgray.png?logo=github
:target: https://github.com/OCA/web-api/tree/12.0/webservice_soap
:alt: OCA/web-api
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/web-api-12-0/web-api-12-0-webservice_soap
: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/web-api&target_branch=12.0
:alt: Try me on Runboat

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

Extends webservice to manage SOAP protocol services under
Web Services Description Language (WSDL).

**Table of contents**

.. contents::
:local:

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/web-api/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/web-api/issues/new?body=module:%20webservice_soap%0Aversion:%2012.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
~~~~~~~

* ForgeFlow

Contributors
~~~~~~~~~~~~

* Héctor Villarreal Ortega <[email protected]>

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/web-api <https://github.com/OCA/web-api/tree/12.0/webservice_soap>`_ 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 webservice_soap/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import components
from . import models
16 changes: 16 additions & 0 deletions webservice_soap/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "Webservice SOAP",
"summary": """
Defines webservice to manage soap sevices""",
"version": "12.0.1.0.0",
"license": "AGPL-3",
"author": "ForgeFlow, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/web-api",
"depends": ["webservice"],
"data": [
"views/webservice_backend_views.xml",
],
"external_dependencies": {"python": ["zeep"]},
"installable": True,
"application": False,
}
1 change: 1 addition & 0 deletions webservice_soap/components/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import soap_adapter
64 changes: 64 additions & 0 deletions webservice_soap/components/soap_adapter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import logging

from requests import Session
from requests.auth import HTTPBasicAuth
from zeep import Client, Settings
from zeep.transports import Transport

from odoo import _
from odoo.exceptions import ValidationError
from odoo.addons.component.core import Component

_logger = logging.getLogger(__name__)


class SoapAdapter(Component):
_name = "base.soap"
_inherit = "base.webservice.adapter"
_webservice_protocol = "soap"

def _get_settings(self):
return Settings(
strict=False,
xml_huge_tree=True,
)

def _get_session(self):
if self.collection.auth_type == "user_pwd":
if not self.collection.username and not self.collection.password:
raise ValidationError(_("Missing username and/or password"))
session = Session()
session.auth = HTTPBasicAuth(
self.collection.username,
self.collection.password
)
return session
return None

def _prepare_client(self):
client_config_dict = {
"wsdl": self.collection.url,
}
settings = self._get_settings()
if settings:
client_config_dict['settings'] = settings
session = self._get_session()
if session:
client_config_dict['transport'] = Transport(session=session)
if self.collection.soap_service_name:
client_config_dict['service_name'] = self.collection.soap_service_name
if self.collection.soap_port_name:
client_config_dict['port_name'] = self.collection.soap_port_name
return client_config_dict

def _get_client(self):
return Client(
**self._prepare_client()
)

def __getattr__(self, attr):
if getattr(self, attr):
return getattr(self, attr)
client = self._get_client()
service = client.service
return getattr(service, attr)
1 change: 1 addition & 0 deletions webservice_soap/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import webservice_backend
19 changes: 19 additions & 0 deletions webservice_soap/models/webservice_backend.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from odoo import fields, models


class WebserviceBackend(models.Model):
_inherit = "webservice.backend"

protocol = fields.Selection(
selection_add=[
("soap", "SOAP"),
],
)
soap_service_name = fields.Char(
help="The service name for the service binding. "
"Defaults to the first service in the WSDL document."
)
soap_port_name = fields.Char(
help="The port name for the default binding. Defaults to the "
"first port defined in the service element in the WSDL document."
)
1 change: 1 addition & 0 deletions webservice_soap/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Héctor Villarreal Ortega <[email protected]>
2 changes: 2 additions & 0 deletions webservice_soap/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Extends webservice to manage SOAP protocol services under
Web Services Description Language (WSDL).
Loading
Loading