diff --git a/setup/.setuptools-odoo-make-default-ignore b/setup/.setuptools-odoo-make-default-ignore new file mode 100644 index 00000000..207e6153 --- /dev/null +++ b/setup/.setuptools-odoo-make-default-ignore @@ -0,0 +1,2 @@ +# addons listed in this file are ignored by +# setuptools-odoo-make-default (one addon per line) diff --git a/setup/README b/setup/README new file mode 100644 index 00000000..a63d633e --- /dev/null +++ b/setup/README @@ -0,0 +1,2 @@ +To learn more about this directory, please visit +https://pypi.python.org/pypi/setuptools-odoo diff --git a/setup/webservice/odoo/addons/webservice b/setup/webservice/odoo/addons/webservice new file mode 120000 index 00000000..e5aa0fcb --- /dev/null +++ b/setup/webservice/odoo/addons/webservice @@ -0,0 +1 @@ +../../../../webservice \ No newline at end of file diff --git a/setup/webservice/setup.py b/setup/webservice/setup.py new file mode 100644 index 00000000..28c57bb6 --- /dev/null +++ b/setup/webservice/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/webservice/README.rst b/webservice/README.rst new file mode 100644 index 00000000..80739c44 --- /dev/null +++ b/webservice/README.rst @@ -0,0 +1,87 @@ +========== +WebService +========== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:c507ac3d223fcff3d1e2326f1bc4f9545c332e0adc575150a75a0dbdad6b6de8 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png + :target: https://odoo-community.org/page/development-status + :alt: Production/Stable +.. |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/16.0/webservice + :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-16-0/web-api-16-0-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/web-api&target_branch=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module creates WebService frameworks to be used globally. + +The module introduces support for HTTP Request protocol. The webservice HTTP call returns by default the content of the response. A context 'content_only' can be passed to get the full response object. + +**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 +* Camptocamp + +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. + +.. |maintainer-etobella| image:: https://github.com/etobella.png?size=40px + :target: https://github.com/etobella + :alt: etobella + +Current `maintainer `__: + +|maintainer-etobella| + +This module is part of the `OCA/web-api `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/webservice/__init__.py b/webservice/__init__.py new file mode 100644 index 00000000..f24d3e24 --- /dev/null +++ b/webservice/__init__.py @@ -0,0 +1,2 @@ +from . import components +from . import models diff --git a/webservice/__manifest__.py b/webservice/__manifest__.py new file mode 100644 index 00000000..566cbc50 --- /dev/null +++ b/webservice/__manifest__.py @@ -0,0 +1,24 @@ +# Copyright 2020 Creu Blanca +# Copyright 2022 Camptocamp SA +# @author Simone Orsi +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + + +{ + "name": "WebService", + "summary": """ + Defines webservice abstract definition to be used generally""", + "version": "12.0.1.0.0", + "license": "AGPL-3", + "development_status": "Production/Stable", + "maintainers": ["etobella"], + "author": "Creu Blanca, Camptocamp, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/web-api", + "depends": ["component", "server_environment"], + "data": [ + "security/ir.model.access.csv", + "security/ir_rule.xml", + "views/webservice_backend.xml", + ], + "demo": [], +} diff --git a/webservice/components/__init__.py b/webservice/components/__init__.py new file mode 100644 index 00000000..4647bfb3 --- /dev/null +++ b/webservice/components/__init__.py @@ -0,0 +1,2 @@ +from . import base_adapter +from . import request_adapter diff --git a/webservice/components/base_adapter.py b/webservice/components/base_adapter.py new file mode 100644 index 00000000..8ac2b380 --- /dev/null +++ b/webservice/components/base_adapter.py @@ -0,0 +1,19 @@ +# Copyright 2020 Creu Blanca +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo.addons.component.core import AbstractComponent + + +class BaseWebServiceAdapter(AbstractComponent): + _name = "base.webservice.adapter" + _collection = "webservice.backend" + _webservice_protocol = False + _usage = "webservice.request" + + @classmethod + def _component_match(cls, work, usage=None, model_name=None, **kw): + """Override to customize match. + Registry lookup filtered by usage and model_name when landing here. + Now, narrow match to `_match_attrs` attributes. + """ + return kw.get("webservice_protocol") in (None, cls._webservice_protocol) diff --git a/webservice/components/request_adapter.py b/webservice/components/request_adapter.py new file mode 100644 index 00000000..06c19a28 --- /dev/null +++ b/webservice/components/request_adapter.py @@ -0,0 +1,84 @@ +# Copyright 2020 Creu Blanca +# Copyright 2022 Camptocamp SA +# @author Simone Orsi +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +import requests + +from odoo.addons.component.core import Component + + +class BaseRestRequestsAdapter(Component): + _name = "base.requests" + _webservice_protocol = "http" + _inherit = "base.webservice.adapter" + + # TODO: url and url_params could come from work_ctx + def _request(self, method, url=None, url_params=None, **kwargs): + url = self._get_url(url=url, url_params=url_params) + content_only = kwargs.pop("content_only", True) + new_kwargs = kwargs.copy() + new_kwargs.update( + { + "auth": self._get_auth(**kwargs), + "headers": self._get_headers(**kwargs), + "timeout": None, + } + ) + # pylint: disable=E8106 + request = requests.request(method, url, **new_kwargs) + request.raise_for_status() + if content_only: + return request.content + return request + + def get(self, **kwargs): + return self._request("get", **kwargs) + + def post(self, **kwargs): + return self._request("post", **kwargs) + + def put(self, **kwargs): + return self._request("put", **kwargs) + + def _get_auth(self, auth=False, **kwargs): + if auth: + return auth + handler = getattr(self, "_get_auth_for_" + self.collection.auth_type, None) + return handler(**kwargs) if handler else None + + def _get_auth_for_user_pwd(self, **kw): + if self.collection.username and self.collection.password: + return self.collection.username, self.collection.password + return None + + def _get_headers(self, content_type=False, headers=False, **kwargs): + headers = headers or {} + result = { + "Content-Type": content_type or self.collection.content_type, + } + handler = getattr(self, "_get_headers_for_" + self.collection.auth_type, None) + if handler: + headers.update(handler(**kwargs)) + result.update(headers) + return result + + def _get_headers_for_api_key(self, **kw): + return {self.collection.api_key_header: self.collection.api_key} + + def _get_url(self, url=None, url_params=None, **kwargs): + if not url: + url = self.collection.url + elif not url.startswith(self.collection.url): + if not url.startswith("http"): + url = "{collection_url}/{url}".format( + collection_url=self.collection.url.rstrip('/'), + url=url.lstrip('/') + ) + else: + # TODO: if url is given, we should validate the domain + # to avoid abusing a webservice backend for different calls. + pass + + url_params = url_params or kwargs + return url.format(**url_params) diff --git a/webservice/controllers/oauth2.py b/webservice/controllers/oauth2.py new file mode 100644 index 00000000..575fdef0 --- /dev/null +++ b/webservice/controllers/oauth2.py @@ -0,0 +1,58 @@ +# Copyright 2024 Camptocamp SA +# @author Alexandre Fayolle +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +import json +import logging + +from oauthlib.oauth2.rfc6749 import errors +from werkzeug.urls import url_encode + +from odoo import http +from odoo.http import request + +_logger = logging.getLogger(__name__) + + +class OAuth2Controller(http.Controller): + @http.route( + "/webservice//oauth2/redirect", + type="http", + auth="public", + csrf=False, + ) + def redirect(self, backend_id, **params): + backend = request.env["webservice.backend"].browse(backend_id).sudo() + if backend.auth_type != "oauth2" or backend.oauth2_flow != "web_application": + _logger.error("unexpected backed config for backend %d", backend_id) + raise errors.MismatchingRedirectURIError() + expected_state = backend.oauth2_state + state = params.get("state") + if state != expected_state: + _logger.error("unexpected state: %s", state) + raise errors.MismatchingStateError() + code = params.get("code") + adapter = ( + backend._get_adapter() + ) # we expect an adapter that supports web_application + token = adapter._fetch_token_from_authorization(code) + backend.write({"oauth2_token": json.dumps(token), "oauth2_state": False}) + # after saving the token, redirect to the backend form view + uid = request.session.uid + user = request.env["res.users"].sudo().browse(uid) + cids = request.httprequest.cookies.get("cids", str(user.company_id.id)) + cids = [int(cid) for cid in cids.split(",")] + record_action = backend.get_access_action() + url_params = { + "model": backend._name, + "id": backend.id, + "active_id": backend.id, + "action": record_action.get("id"), + } + view_id = backend.get_formview_id() + if view_id: + url_params["view_id"] = view_id + + if cids: + url_params["cids"] = ",".join([str(cid) for cid in cids]) + url = "/web?#%s" % url_encode(url_params) + return request.redirect(url) diff --git a/webservice/i18n/fr.po b/webservice/i18n/fr.po new file mode 100644 index 00000000..a76baec9 --- /dev/null +++ b/webservice/i18n/fr.po @@ -0,0 +1,407 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * webservice +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2021-06-17 15:48+0000\n" +"Last-Translator: Yves Le Doeuff \n" +"Language-Team: none\n" +"Language: fr\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.3.2\n" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__api_key +#: model:ir.model.fields.selection,name:webservice.selection__webservice_backend__auth_type__api_key +msgid "API Key" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__api_key_env_default +msgid "API Key Env Default" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__api_key_header +msgid "API Key header" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__api_key_header_env_default +msgid "API Key header Env Default" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__api_key_env_is_editable +msgid "Api Key Env Is Editable" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__api_key_header_env_is_editable +msgid "Api Key Header Env Is Editable" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__oauth2_audience +msgid "Audience" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__oauth2_audience_env_default +msgid "Audience Env Default" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__auth_type +msgid "Auth Type" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__auth_type_env_default +msgid "Auth Type Env Default" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__auth_type_env_is_editable +msgid "Auth Type Env Is Editable" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__oauth2_authorization_url +msgid "Authorization URL" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__oauth2_authorization_url_env_default +msgid "Authorization URL Env Default" +msgstr "" + +#. module: webservice +#: model:ir.model.fields.selection,name:webservice.selection__webservice_backend__oauth2_flow__backend_application +msgid "Backend Application (Client Credentials Grant)" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__oauth2_clientid +msgid "Client ID" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__oauth2_clientid_env_default +msgid "Client ID Env Default" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__oauth2_client_secret +msgid "Client Secret" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__oauth2_client_secret_env_default +msgid "Client Secret Env Default" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__company_id +msgid "Company" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__content_type +msgid "Content Type" +msgstr "Type de contenu" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__content_type_env_default +msgid "Content Type Env Default" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__content_type_env_is_editable +msgid "Content Type Env Is Editable" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__create_uid +msgid "Created by" +msgstr "Créé par" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__create_date +msgid "Created on" +msgstr "Crée le" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__display_name +msgid "Display Name" +msgstr "Afficher Nom" + +#. module: webservice +#: model:ir.model.fields.selection,name:webservice.selection__webservice_backend__content_type__application/x-www-form-urlencoded +msgid "Form" +msgstr "Formulaire" + +#. module: webservice +#: model:ir.model.fields.selection,name:webservice.selection__webservice_backend__protocol__http +msgid "HTTP Request" +msgstr "Requête HTTP" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__id +msgid "ID" +msgstr "ID" + +#. module: webservice +#: model:ir.model.fields.selection,name:webservice.selection__webservice_backend__content_type__application/json +msgid "JSON" +msgstr "JSON" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend____last_update +msgid "Last Modified on" +msgstr "Dernière modification le" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__write_uid +msgid "Last Updated by" +msgstr "Dernière mise à jour par" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__write_date +msgid "Last Updated on" +msgstr "Dernière mise à jour le" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__name +msgid "Name" +msgstr "Nom" + +#. module: webservice +#: model_terms:ir.ui.view,arch_db:webservice.webservice_backend_form_view +msgid "OAuth Authorize" +msgstr "" + +#. module: webservice +#: model:ir.model.fields.selection,name:webservice.selection__webservice_backend__auth_type__oauth2 +msgid "OAuth2" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__oauth2_audience_env_is_editable +msgid "Oauth2 Audience Env Is Editable" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__oauth2_authorization_url_env_is_editable +msgid "Oauth2 Authorization Url Env Is Editable" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__oauth2_client_secret_env_is_editable +msgid "Oauth2 Client Secret Env Is Editable" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__oauth2_clientid_env_is_editable +msgid "Oauth2 Clientid Env Is Editable" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__oauth2_flow +msgid "Oauth2 Flow" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__oauth2_flow_env_default +msgid "Oauth2 Flow Env Default" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__oauth2_flow_env_is_editable +msgid "Oauth2 Flow Env Is Editable" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__oauth2_scope +msgid "Oauth2 Scope" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__oauth2_scope_env_default +msgid "Oauth2 Scope Env Default" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__oauth2_scope_env_is_editable +msgid "Oauth2 Scope Env Is Editable" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__oauth2_state +msgid "Oauth2 State" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__oauth2_token +msgid "Oauth2 Token" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__oauth2_token_url_env_is_editable +msgid "Oauth2 Token Url Env Is Editable" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__password +msgid "Password" +msgstr "Mot de passe" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__password_env_default +msgid "Password Env Default" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__password_env_is_editable +msgid "Password Env Is Editable" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__protocol +msgid "Protocol" +msgstr "Protocole" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__protocol_env_default +msgid "Protocol Env Default" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__protocol_env_is_editable +msgid "Protocol Env Is Editable" +msgstr "" + +#. module: webservice +#: model:ir.model.fields.selection,name:webservice.selection__webservice_backend__auth_type__none +msgid "Public" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__redirect_url +msgid "Redirect Url" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__server_env_defaults +msgid "Server Env Defaults" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__tech_name +msgid "Tech Name" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,help:webservice.field_webservice_backend__redirect_url +msgid "The redirect URL to be used as part of the OAuth2 authorisation flow" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__oauth2_token_url +msgid "Token URL" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__oauth2_token_url_env_default +msgid "Token URL Env Default" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,help:webservice.field_webservice_backend__tech_name +msgid "Unique name for technical purposes. Eg: server env keys." +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__url +msgid "Url" +msgstr "Url" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__url_env_default +msgid "Url Env Default" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__url_env_is_editable +msgid "Url Env Is Editable" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__username +msgid "Username" +msgstr "nom d'utilisateur :" + +#. module: webservice +#: model:ir.model.fields.selection,name:webservice.selection__webservice_backend__auth_type__user_pwd +msgid "Username & password" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__username_env_default +msgid "Username Env Default" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__username_env_is_editable +msgid "Username Env Is Editable" +msgstr "" + +#. module: webservice +#: model:ir.model.fields.selection,name:webservice.selection__webservice_backend__oauth2_flow__web_application +msgid "Web Application (Authorization Code Grant)" +msgstr "" + +#. module: webservice +#: model:ir.actions.act_window,name:webservice.webservice_backend_act_window +#: model:ir.model,name:webservice.model_webservice_backend +#: model:ir.ui.menu,name:webservice.webservice_backend_menu +msgid "WebService Backend" +msgstr "" + +#. module: webservice +#. odoo-python +#: code:addons/webservice/models/webservice_backend.py:0 +#, python-format +msgid "" +"Webservice '%(name)s' requires '%(auth_type)s' authentication. However, the " +"following field(s) are not valued: %(fields)s" +msgstr "" + +#. module: webservice +#: model:ir.model.fields.selection,name:webservice.selection__webservice_backend__content_type__application/xml +msgid "XML" +msgstr "XLM" + +#. module: webservice +#: model:ir.model.fields,help:webservice.field_webservice_backend__oauth2_state +msgid "" +"random key generated when authorization flow starts to ensure that no CSRF " +"attack happen" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,help:webservice.field_webservice_backend__oauth2_scope +#: model:ir.model.fields,help:webservice.field_webservice_backend__oauth2_scope_env_default +msgid "scope of the the authorization" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,help:webservice.field_webservice_backend__oauth2_token +msgid "the OAuth2 token (serialized JSON)" +msgstr "" diff --git a/webservice/i18n/it.po b/webservice/i18n/it.po new file mode 100644 index 00000000..1a001adf --- /dev/null +++ b/webservice/i18n/it.po @@ -0,0 +1,412 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * webservice +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2024-10-29 12:06+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.6.2\n" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__api_key +#: model:ir.model.fields.selection,name:webservice.selection__webservice_backend__auth_type__api_key +msgid "API Key" +msgstr "Chiave API" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__api_key_env_default +msgid "API Key Env Default" +msgstr "Chiave API predefinita dell'ambiente" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__api_key_header +msgid "API Key header" +msgstr "Intestazione chiave API" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__api_key_header_env_default +msgid "API Key header Env Default" +msgstr "Intestazione chiave API predefinita dell'ambiente" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__api_key_env_is_editable +msgid "Api Key Env Is Editable" +msgstr "La chiave API ambene è modificabile" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__api_key_header_env_is_editable +msgid "Api Key Header Env Is Editable" +msgstr "L'intestazione chiave API ambene è modificabile" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__oauth2_audience +msgid "Audience" +msgstr "Audience" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__oauth2_audience_env_default +msgid "Audience Env Default" +msgstr "Audience predefinito dell'ambiente" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__auth_type +msgid "Auth Type" +msgstr "Tipo autorizzazione" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__auth_type_env_default +msgid "Auth Type Env Default" +msgstr "Tipo autoizzazione predefinito dell'ambiente" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__auth_type_env_is_editable +msgid "Auth Type Env Is Editable" +msgstr "Il tipo autrizzazione ambiente è modificabile" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__oauth2_authorization_url +msgid "Authorization URL" +msgstr "URL autorizzazione" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__oauth2_authorization_url_env_default +msgid "Authorization URL Env Default" +msgstr "URL autorizzazione predefinito dell'ambiente" + +#. module: webservice +#: model:ir.model.fields.selection,name:webservice.selection__webservice_backend__oauth2_flow__backend_application +msgid "Backend Application (Client Credentials Grant)" +msgstr "Applicazione backend (concessione credenziali client)" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__oauth2_clientid +msgid "Client ID" +msgstr "ID cliente" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__oauth2_clientid_env_default +msgid "Client ID Env Default" +msgstr "ID client predefinito dell'ambiente" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__oauth2_client_secret +msgid "Client Secret" +msgstr "Chiave segreta client" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__oauth2_client_secret_env_default +msgid "Client Secret Env Default" +msgstr "Chiave csegreta client predefinita dell'ambiente" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__company_id +msgid "Company" +msgstr "Azienda" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__content_type +msgid "Content Type" +msgstr "Tipo di contenuto" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__content_type_env_default +msgid "Content Type Env Default" +msgstr "Tipo contenuto predefinito dell'ambiente" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__content_type_env_is_editable +msgid "Content Type Env Is Editable" +msgstr "Il tipo contenuto ambiente è modificabile" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__create_uid +msgid "Created by" +msgstr "Creato da" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__create_date +msgid "Created on" +msgstr "Creato il" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__display_name +msgid "Display Name" +msgstr "Nome visualizzato" + +#. module: webservice +#: model:ir.model.fields.selection,name:webservice.selection__webservice_backend__content_type__application/x-www-form-urlencoded +msgid "Form" +msgstr "Maschera" + +#. module: webservice +#: model:ir.model.fields.selection,name:webservice.selection__webservice_backend__protocol__http +msgid "HTTP Request" +msgstr "Richiesta HTTP" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__id +msgid "ID" +msgstr "ID" + +#. module: webservice +#: model:ir.model.fields.selection,name:webservice.selection__webservice_backend__content_type__application/json +msgid "JSON" +msgstr "JSON" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend____last_update +msgid "Last Modified on" +msgstr "Ultima modifica il" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__write_uid +msgid "Last Updated by" +msgstr "Ultimo aggiornamento di" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__write_date +msgid "Last Updated on" +msgstr "Ultimo aggiornamento il" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__name +msgid "Name" +msgstr "Nome" + +#. module: webservice +#: model_terms:ir.ui.view,arch_db:webservice.webservice_backend_form_view +msgid "OAuth Authorize" +msgstr "Autorizzazione OAuth" + +#. module: webservice +#: model:ir.model.fields.selection,name:webservice.selection__webservice_backend__auth_type__oauth2 +msgid "OAuth2" +msgstr "OAuth2" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__oauth2_audience_env_is_editable +msgid "Oauth2 Audience Env Is Editable" +msgstr "Audience OAuth2 ambiente è modificabile" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__oauth2_authorization_url_env_is_editable +msgid "Oauth2 Authorization Url Env Is Editable" +msgstr "URL autorizzazione OAuth2 è modificabile" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__oauth2_client_secret_env_is_editable +msgid "Oauth2 Client Secret Env Is Editable" +msgstr "Chiave segreta OAuth client è modificabile" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__oauth2_clientid_env_is_editable +msgid "Oauth2 Clientid Env Is Editable" +msgstr "ID client OAuth2 ambiente è modificabile" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__oauth2_flow +msgid "Oauth2 Flow" +msgstr "Flusso OAuth2" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__oauth2_flow_env_default +msgid "Oauth2 Flow Env Default" +msgstr "Flusso OAuth2 predefinito dell'ambiente" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__oauth2_flow_env_is_editable +msgid "Oauth2 Flow Env Is Editable" +msgstr "Flusso OAuth2 ambiente è modificabile" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__oauth2_scope +msgid "Oauth2 Scope" +msgstr "Ambito OAuth2" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__oauth2_scope_env_default +msgid "Oauth2 Scope Env Default" +msgstr "Ambito OAuth2 predefinito dell'ambiente" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__oauth2_scope_env_is_editable +msgid "Oauth2 Scope Env Is Editable" +msgstr "Ambito OAuth2 ambiente è modificabile" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__oauth2_state +msgid "Oauth2 State" +msgstr "Stato OAuth2" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__oauth2_token +msgid "Oauth2 Token" +msgstr "Token OAuth2" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__oauth2_token_url_env_is_editable +msgid "Oauth2 Token Url Env Is Editable" +msgstr "URL token OAuth2 ambiente è modificabile" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__password +msgid "Password" +msgstr "Password" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__password_env_default +msgid "Password Env Default" +msgstr "Password predefinita dell'ambiente" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__password_env_is_editable +msgid "Password Env Is Editable" +msgstr "Password ambiente è modificabile" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__protocol +msgid "Protocol" +msgstr "Protcollo" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__protocol_env_default +msgid "Protocol Env Default" +msgstr "Protocollo predefinito dell'ambiente" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__protocol_env_is_editable +msgid "Protocol Env Is Editable" +msgstr "Protocollo ambiente è modificabile" + +#. module: webservice +#: model:ir.model.fields.selection,name:webservice.selection__webservice_backend__auth_type__none +msgid "Public" +msgstr "Pubblico" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__redirect_url +msgid "Redirect Url" +msgstr "URL inoltro" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__server_env_defaults +msgid "Server Env Defaults" +msgstr "Server predefinito dell'ambiente" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__tech_name +msgid "Tech Name" +msgstr "Nome tecnico" + +#. module: webservice +#: model:ir.model.fields,help:webservice.field_webservice_backend__redirect_url +msgid "The redirect URL to be used as part of the OAuth2 authorisation flow" +msgstr "" +"L'URL di inoltro da utilizzare come parte del flusso di autorizzazione OAuth2" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__oauth2_token_url +msgid "Token URL" +msgstr "URL token" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__oauth2_token_url_env_default +msgid "Token URL Env Default" +msgstr "URL token predefinito dell'ambiente" + +#. module: webservice +#: model:ir.model.fields,help:webservice.field_webservice_backend__tech_name +msgid "Unique name for technical purposes. Eg: server env keys." +msgstr "Nome univoco per motivi tecnici. Es: chiavi server ambiente." + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__url +msgid "Url" +msgstr "URL" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__url_env_default +msgid "Url Env Default" +msgstr "URL predefinito dell'ambiente" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__url_env_is_editable +msgid "Url Env Is Editable" +msgstr "URL ambiene è modificabile" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__username +msgid "Username" +msgstr "Nome utente" + +#. module: webservice +#: model:ir.model.fields.selection,name:webservice.selection__webservice_backend__auth_type__user_pwd +msgid "Username & password" +msgstr "Nome utente e password" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__username_env_default +msgid "Username Env Default" +msgstr "Nome utente predefinito dell'ambiente" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__username_env_is_editable +msgid "Username Env Is Editable" +msgstr "Nome utente ambiente è modificabile" + +#. module: webservice +#: model:ir.model.fields.selection,name:webservice.selection__webservice_backend__oauth2_flow__web_application +msgid "Web Application (Authorization Code Grant)" +msgstr "Applicazione Web (Concessione codice autorizzazione)" + +#. module: webservice +#: model:ir.actions.act_window,name:webservice.webservice_backend_act_window +#: model:ir.model,name:webservice.model_webservice_backend +#: model:ir.ui.menu,name:webservice.webservice_backend_menu +msgid "WebService Backend" +msgstr "Backend servizio web" + +#. module: webservice +#. odoo-python +#: code:addons/webservice/models/webservice_backend.py:0 +#, python-format +msgid "" +"Webservice '%(name)s' requires '%(auth_type)s' authentication. However, the " +"following field(s) are not valued: %(fields)s" +msgstr "" +"Il webservice '%(name)s' richiede autentIcazione '%(auth_type)s'. Comunque, " +"i seguenti campi non sono calorizzati: %(fields)s" + +#. module: webservice +#: model:ir.model.fields.selection,name:webservice.selection__webservice_backend__content_type__application/xml +msgid "XML" +msgstr "XML" + +#. module: webservice +#: model:ir.model.fields,help:webservice.field_webservice_backend__oauth2_state +msgid "" +"random key generated when authorization flow starts to ensure that no CSRF " +"attack happen" +msgstr "" +"chiave causale generata quando il flusso autorizzazione inizia per " +"assicurare che non si verifichi un accatto CSRF" + +#. module: webservice +#: model:ir.model.fields,help:webservice.field_webservice_backend__oauth2_scope +#: model:ir.model.fields,help:webservice.field_webservice_backend__oauth2_scope_env_default +msgid "scope of the the authorization" +msgstr "ambito dell'autorizzazione" + +#. module: webservice +#: model:ir.model.fields,help:webservice.field_webservice_backend__oauth2_token +msgid "the OAuth2 token (serialized JSON)" +msgstr "il token OAuth2 (JSON serializzato)" diff --git a/webservice/i18n/webservice.pot b/webservice/i18n/webservice.pot new file mode 100644 index 00000000..465f2bd3 --- /dev/null +++ b/webservice/i18n/webservice.pot @@ -0,0 +1,404 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * webservice +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.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: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__api_key +#: model:ir.model.fields.selection,name:webservice.selection__webservice_backend__auth_type__api_key +msgid "API Key" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__api_key_env_default +msgid "API Key Env Default" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__api_key_header +msgid "API Key header" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__api_key_header_env_default +msgid "API Key header Env Default" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__api_key_env_is_editable +msgid "Api Key Env Is Editable" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__api_key_header_env_is_editable +msgid "Api Key Header Env Is Editable" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__oauth2_audience +msgid "Audience" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__oauth2_audience_env_default +msgid "Audience Env Default" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__auth_type +msgid "Auth Type" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__auth_type_env_default +msgid "Auth Type Env Default" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__auth_type_env_is_editable +msgid "Auth Type Env Is Editable" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__oauth2_authorization_url +msgid "Authorization URL" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__oauth2_authorization_url_env_default +msgid "Authorization URL Env Default" +msgstr "" + +#. module: webservice +#: model:ir.model.fields.selection,name:webservice.selection__webservice_backend__oauth2_flow__backend_application +msgid "Backend Application (Client Credentials Grant)" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__oauth2_clientid +msgid "Client ID" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__oauth2_clientid_env_default +msgid "Client ID Env Default" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__oauth2_client_secret +msgid "Client Secret" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__oauth2_client_secret_env_default +msgid "Client Secret Env Default" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__company_id +msgid "Company" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__content_type +msgid "Content Type" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__content_type_env_default +msgid "Content Type Env Default" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__content_type_env_is_editable +msgid "Content Type Env Is Editable" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__create_uid +msgid "Created by" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__create_date +msgid "Created on" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__display_name +msgid "Display Name" +msgstr "" + +#. module: webservice +#: model:ir.model.fields.selection,name:webservice.selection__webservice_backend__content_type__application/x-www-form-urlencoded +msgid "Form" +msgstr "" + +#. module: webservice +#: model:ir.model.fields.selection,name:webservice.selection__webservice_backend__protocol__http +msgid "HTTP Request" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__id +msgid "ID" +msgstr "" + +#. module: webservice +#: model:ir.model.fields.selection,name:webservice.selection__webservice_backend__content_type__application/json +msgid "JSON" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend____last_update +msgid "Last Modified on" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__write_uid +msgid "Last Updated by" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__write_date +msgid "Last Updated on" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__name +msgid "Name" +msgstr "" + +#. module: webservice +#: model_terms:ir.ui.view,arch_db:webservice.webservice_backend_form_view +msgid "OAuth Authorize" +msgstr "" + +#. module: webservice +#: model:ir.model.fields.selection,name:webservice.selection__webservice_backend__auth_type__oauth2 +msgid "OAuth2" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__oauth2_audience_env_is_editable +msgid "Oauth2 Audience Env Is Editable" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__oauth2_authorization_url_env_is_editable +msgid "Oauth2 Authorization Url Env Is Editable" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__oauth2_client_secret_env_is_editable +msgid "Oauth2 Client Secret Env Is Editable" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__oauth2_clientid_env_is_editable +msgid "Oauth2 Clientid Env Is Editable" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__oauth2_flow +msgid "Oauth2 Flow" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__oauth2_flow_env_default +msgid "Oauth2 Flow Env Default" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__oauth2_flow_env_is_editable +msgid "Oauth2 Flow Env Is Editable" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__oauth2_scope +msgid "Oauth2 Scope" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__oauth2_scope_env_default +msgid "Oauth2 Scope Env Default" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__oauth2_scope_env_is_editable +msgid "Oauth2 Scope Env Is Editable" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__oauth2_state +msgid "Oauth2 State" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__oauth2_token +msgid "Oauth2 Token" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__oauth2_token_url_env_is_editable +msgid "Oauth2 Token Url Env Is Editable" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__password +msgid "Password" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__password_env_default +msgid "Password Env Default" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__password_env_is_editable +msgid "Password Env Is Editable" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__protocol +msgid "Protocol" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__protocol_env_default +msgid "Protocol Env Default" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__protocol_env_is_editable +msgid "Protocol Env Is Editable" +msgstr "" + +#. module: webservice +#: model:ir.model.fields.selection,name:webservice.selection__webservice_backend__auth_type__none +msgid "Public" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__redirect_url +msgid "Redirect Url" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__server_env_defaults +msgid "Server Env Defaults" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__tech_name +msgid "Tech Name" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,help:webservice.field_webservice_backend__redirect_url +msgid "The redirect URL to be used as part of the OAuth2 authorisation flow" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__oauth2_token_url +msgid "Token URL" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__oauth2_token_url_env_default +msgid "Token URL Env Default" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,help:webservice.field_webservice_backend__tech_name +msgid "Unique name for technical purposes. Eg: server env keys." +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__url +msgid "Url" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__url_env_default +msgid "Url Env Default" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__url_env_is_editable +msgid "Url Env Is Editable" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__username +msgid "Username" +msgstr "" + +#. module: webservice +#: model:ir.model.fields.selection,name:webservice.selection__webservice_backend__auth_type__user_pwd +msgid "Username & password" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__username_env_default +msgid "Username Env Default" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,field_description:webservice.field_webservice_backend__username_env_is_editable +msgid "Username Env Is Editable" +msgstr "" + +#. module: webservice +#: model:ir.model.fields.selection,name:webservice.selection__webservice_backend__oauth2_flow__web_application +msgid "Web Application (Authorization Code Grant)" +msgstr "" + +#. module: webservice +#: model:ir.actions.act_window,name:webservice.webservice_backend_act_window +#: model:ir.model,name:webservice.model_webservice_backend +#: model:ir.ui.menu,name:webservice.webservice_backend_menu +msgid "WebService Backend" +msgstr "" + +#. module: webservice +#. odoo-python +#: code:addons/webservice/models/webservice_backend.py:0 +#, python-format +msgid "" +"Webservice '%(name)s' requires '%(auth_type)s' authentication. However, the " +"following field(s) are not valued: %(fields)s" +msgstr "" + +#. module: webservice +#: model:ir.model.fields.selection,name:webservice.selection__webservice_backend__content_type__application/xml +msgid "XML" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,help:webservice.field_webservice_backend__oauth2_state +msgid "" +"random key generated when authorization flow starts to ensure that no CSRF " +"attack happen" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,help:webservice.field_webservice_backend__oauth2_scope +#: model:ir.model.fields,help:webservice.field_webservice_backend__oauth2_scope_env_default +msgid "scope of the the authorization" +msgstr "" + +#. module: webservice +#: model:ir.model.fields,help:webservice.field_webservice_backend__oauth2_token +msgid "the OAuth2 token (serialized JSON)" +msgstr "" diff --git a/webservice/models/__init__.py b/webservice/models/__init__.py new file mode 100644 index 00000000..c08fb9a9 --- /dev/null +++ b/webservice/models/__init__.py @@ -0,0 +1 @@ +from . import webservice_backend diff --git a/webservice/models/webservice_backend.py b/webservice/models/webservice_backend.py new file mode 100644 index 00000000..e7bb1103 --- /dev/null +++ b/webservice/models/webservice_backend.py @@ -0,0 +1,105 @@ +# Copyright 2020 Creu Blanca +# Copyright 2022 Camptocamp SA +# @author Simone Orsi +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import _, api, exceptions, fields, models + + +class WebserviceBackend(models.Model): + + _name = "webservice.backend" + _inherit = ["collection.base", "server.env.techname.mixin", "server.env.mixin"] + _description = "WebService Backend" + + name = fields.Char(required=True) + tech_name = fields.Char(required=True) + protocol = fields.Selection([("http", "HTTP Request")], required=True) + url = fields.Char(required=True) + auth_type = fields.Selection( + selection=[ + ("none", "Public"), + ("user_pwd", "Username & password"), + ("api_key", "API Key"), + ], + default="user_pwd", + required=True, + ) + username = fields.Char(auth_type="user_pwd") + password = fields.Char(auth_type="user_pwd") + api_key = fields.Char(string="API Key", auth_type="api_key") + api_key_header = fields.Char(string="API Key header", auth_type="api_key") + content_type = fields.Selection( + [ + ("application/json", "JSON"), + ("application/xml", "XML"), + ("application/x-www-form-urlencoded", "Form"), + ], + required=True, + ) + company_id = fields.Many2one("res.company", string="Company") + + @api.constrains("auth_type") + def _check_auth_type(self): + valid_fields = { + k: v for k, v in self._fields.items() if hasattr(v, "auth_type") + } + for rec in self: + if rec.auth_type == "none": + continue + _fields = [v for v in valid_fields.values() if v.auth_type == rec.auth_type] + missing = [] + for _field in _fields: + if not rec[_field.name]: + missing.append(_field) + if missing: + raise exceptions.UserError(rec._msg_missing_auth_param(missing)) + + def _msg_missing_auth_param(self, missing_fields): + def get_selection_value(fname): + return self._fields.get(fname).convert_to_export(self[fname], self) + + return _( + "Webservice '%(name)s' requires '%(auth_type)s' authentication. " + "However, the following field(s) are not valued: %(fields)s" + ) % { + "name": self.name, + "auth_type": get_selection_value("auth_type"), + "fields": ", ".join([f.string for f in missing_fields]), + } + + def _valid_field_parameter(self, field, name): + extra_params = ("auth_type",) + return name in extra_params or super()._valid_field_parameter(field, name) + + def call(self, method, *args, **kwargs): + return getattr(self._get_adapter(), method)(*args, **kwargs) + + def _get_adapter(self): + with self.work_on(self._name) as work: + return work.component( + usage="webservice.request", webservice_protocol=self.protocol + ) + + @property + def _server_env_fields(self): + base_fields = super()._server_env_fields + webservice_fields = { + "protocol": {}, + "url": {}, + "auth_type": {}, + "username": {}, + "password": {}, + "api_key": {}, + "api_key_header": {}, + "content_type": {}, + } + webservice_fields.update(base_fields) + return webservice_fields + + def _compute_server_env(self): + # OVERRIDE: reset ``oauth2_flow`` when ``auth_type`` is not "oauth2", even if + # defined otherwise in server env vars + res = super()._compute_server_env() + self.filtered(lambda r: r.auth_type != "oauth2").oauth2_flow = None + return res diff --git a/webservice/readme/CONTRIBUTORS.rst b/webservice/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000..1e97bc2f --- /dev/null +++ b/webservice/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* Enric Tobella +* Alexandre Fayolle +* Guillem Casassas diff --git a/webservice/readme/DESCRIPTION.rst b/webservice/readme/DESCRIPTION.rst new file mode 100644 index 00000000..cdd44bd7 --- /dev/null +++ b/webservice/readme/DESCRIPTION.rst @@ -0,0 +1,3 @@ +This module creates WebService frameworks to be used globally. + +The module introduces support for HTTP Request protocol. The webservice HTTP call returns by default the content of the response. A context 'content_only' can be passed to get the full response object. diff --git a/webservice/security/ir.model.access.csv b/webservice/security/ir.model.access.csv new file mode 100644 index 00000000..f8bb5166 --- /dev/null +++ b/webservice/security/ir.model.access.csv @@ -0,0 +1,2 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_webservice_backend_edit,webservice_backend edit,model_webservice_backend,base.group_system,1,1,1,1 diff --git a/webservice/security/ir_rule.xml b/webservice/security/ir_rule.xml new file mode 100644 index 00000000..9942a3c8 --- /dev/null +++ b/webservice/security/ir_rule.xml @@ -0,0 +1,10 @@ + + + + webservice_backend multi-company + + ['|',('company_id','=',False), ('company_id', 'child_of', [user.company_id.id])] + + diff --git a/webservice/static/description/icon.png b/webservice/static/description/icon.png new file mode 100644 index 00000000..3a0328b5 Binary files /dev/null and b/webservice/static/description/icon.png differ diff --git a/webservice/static/description/index.html b/webservice/static/description/index.html new file mode 100644 index 00000000..620bccb0 --- /dev/null +++ b/webservice/static/description/index.html @@ -0,0 +1,427 @@ + + + + + +WebService + + + +
+

WebService

+ + +

Production/Stable License: AGPL-3 OCA/web-api Translate me on Weblate Try me on Runboat

+

This module creates WebService frameworks to be used globally.

+

The module introduces support for HTTP Request protocol. The webservice HTTP call returns by default the content of the response. A context ‘content_only’ can be passed to get the full response object.

+

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
  • +
  • Camptocamp
  • +
+
+
+

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.

+

Current maintainer:

+

etobella

+

This module is part of the OCA/web-api project on GitHub.

+

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

+
+
+
+ + diff --git a/webservice/tests/__init__.py b/webservice/tests/__init__.py new file mode 100644 index 00000000..c7c6b2c0 --- /dev/null +++ b/webservice/tests/__init__.py @@ -0,0 +1 @@ +from . import test_webservice diff --git a/webservice/tests/common.py b/webservice/tests/common.py new file mode 100644 index 00000000..5d14ed8b --- /dev/null +++ b/webservice/tests/common.py @@ -0,0 +1,42 @@ +# Copyright 2020 Creu Blanca +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +import mock +from contextlib import contextmanager +from odoo.tests.common import tagged + +from odoo.addons.component.tests.common import TransactionComponentCase + + +@tagged("-at_install", "post_install") +class CommonWebService(TransactionComponentCase): + def _setup_context(self): + return dict( + self.env.context, tracking_disable=True, test_queue_job_no_delay=True, + ) + + def _setup_env(self): + self.env = self.env(context=self._setup_context()) + + def _setup_records(self): + pass + + def setUp(self): + super(CommonWebService, self).setUp() + self._setup_env() + self._setup_records() + + +@contextmanager +def mock_cursor(cr): + with mock.patch("odoo.sql_db.Connection.cursor") as mocked_cursor_call: + org_close = cr.close + org_autocommit = cr.autocommit + try: + cr.close = mock.Mock() + cr.autocommit = mock.Mock() + cr.commit = mock.Mock() + mocked_cursor_call.return_value = cr + yield + finally: + cr.close = org_close + cr.autocommit = org_autocommit diff --git a/webservice/tests/test_webservice.py b/webservice/tests/test_webservice.py new file mode 100644 index 00000000..4df21af6 --- /dev/null +++ b/webservice/tests/test_webservice.py @@ -0,0 +1,201 @@ +# Copyright 2020 Creu Blanca +# Copyright 2022 Camptocamp SA +# @author Simone Orsi +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +import httpretty +from requests import auth, exceptions as http_exceptions + +from odoo import exceptions + +from .common import CommonWebService + + +class TestWebService(CommonWebService): + def _setup_records(self): + res = super(TestWebService, self)._setup_records() + self.url = "https://localhost.demo.odoo/" + self.webservice = self.env["webservice.backend"].create( + { + "name": "WebService", + "protocol": "http", + "url": self.url, + "content_type": "application/xml", + "tech_name": "demo_ws", + "auth_type": "none", + } + ) + return res + + def test_web_service_not_found(self): + with self.assertRaises(http_exceptions.ConnectionError): + self.webservice.call("get") + + def test_auth_validation(self): + msg = ( + r"Webservice 'WebService' " + r"requires 'Username & password' authentication. " + r"However, the following field\(s\) are not valued: Username, Password" + ) + with self.assertRaisesRegex(exceptions.ValidationError, msg): + self.webservice.write( + { + "auth_type": "user_pwd", + } + ) + + msg = ( + r"Webservice 'WebService' " + r"requires 'Username & password' authentication. " + r"However, the following field\(s\) are not valued: Password" + ) + with self.assertRaisesRegex(exceptions.ValidationError, msg): + self.webservice.write({"auth_type": "user_pwd", "username": "user"}) + + msg = ( + r"Webservice 'WebService' " + r"requires 'API Key' authentication. " + r"However, the following field\(s\) are not valued: API Key, API Key header" + ) + with self.assertRaisesRegex(exceptions.ValidationError, msg): + self.webservice.write( + { + "auth_type": "api_key", + } + ) + + msg = ( + r"Webservice 'WebService' " + r"requires 'API Key' authentication. " + r"However, the following field\(s\) are not valued: API Key header" + ) + with self.assertRaisesRegex(exceptions.ValidationError, msg): + self.webservice.write( + { + "auth_type": "api_key", + "api_key": "foo", + } + ) + + @httpretty.activate + def test_web_service_get(self): + httpretty.register_uri(httpretty.GET, self.url, body="{}") + result = self.webservice.call("get") + self.assertEqual(result, b"{}") + self.assertEqual(len(httpretty.latest_requests()), 1) + self.assertEqual( + httpretty.latest_requests()[0].headers["Content-Type"], "application/xml" + ) + + @httpretty.activate + def test_web_service_post(self): + httpretty.register_uri(httpretty.POST, self.url, body="{}") + result = self.webservice.call("post", data="demo_response") + self.assertEqual(result, b"{}") + self.assertEqual( + httpretty.latest_requests()[0].headers["Content-Type"], "application/xml" + ) + self.assertEqual(httpretty.latest_requests()[0].body, b"demo_response") + + @httpretty.activate + def test_web_service_put(self): + httpretty.register_uri(httpretty.PUT, self.url, body="{}") + result = self.webservice.call("put", data="demo_response") + self.assertEqual(result, b"{}") + self.assertEqual( + httpretty.latest_requests()[0].headers["Content-Type"], "application/xml" + ) + self.assertEqual(httpretty.latest_requests()[0].body, b"demo_response") + + @httpretty.activate + def test_web_service_backend_username(self): + self.webservice.write( + {"auth_type": "user_pwd", "username": "user", "password": "pass"} + ) + httpretty.register_uri(httpretty.GET, self.url, body="{}") + result = self.webservice.call("get") + self.assertEqual(result, b"{}") + self.assertEqual(len(httpretty.latest_requests()), 1) + self.assertEqual( + httpretty.latest_requests()[0].headers["Content-Type"], "application/xml" + ) + data = auth._basic_auth_str("user", "pass") + self.assertEqual(httpretty.latest_requests()[0].headers["Authorization"], data) + + @httpretty.activate + def test_web_service_username(self): + self.webservice.write( + {"auth_type": "user_pwd", "username": "user", "password": "pass"} + ) + httpretty.register_uri(httpretty.GET, self.url, body="{}") + result = self.webservice.call("get", auth=("user2", "pass2")) + self.assertEqual(result, b"{}") + self.assertEqual(len(httpretty.latest_requests()), 1) + self.assertEqual( + httpretty.latest_requests()[0].headers["Content-Type"], "application/xml" + ) + data = auth._basic_auth_str("user2", "pass2") + self.assertEqual(httpretty.latest_requests()[0].headers["Authorization"], data) + + @httpretty.activate + def test_web_service_backend_api_key(self): + self.webservice.write( + {"auth_type": "api_key", "api_key": "123xyz", "api_key_header": "Api-Key"} + ) + httpretty.register_uri(httpretty.POST, self.url, body="{}") + result = self.webservice.call("post") + self.assertEqual(result, b"{}") + self.assertEqual(len(httpretty.latest_requests()), 1) + self.assertEqual( + httpretty.latest_requests()[0].headers["Content-Type"], "application/xml" + ) + self.assertEqual(httpretty.latest_requests()[0].headers["Api-Key"], "123xyz") + + @httpretty.activate + def test_web_service_headers(self): + httpretty.register_uri(httpretty.GET, self.url, body="{}") + result = self.webservice.call("get", headers={"demo_header": "HEADER"}) + self.assertEqual(result, b"{}") + self.assertEqual(len(httpretty.latest_requests()), 1) + self.assertEqual( + httpretty.latest_requests()[0].headers["Content-Type"], "application/xml" + ) + self.assertEqual( + httpretty.latest_requests()[0].headers["demo_header"], + "HEADER" + ) + + @httpretty.activate + def test_web_service_call_args(self): + url = "https://custom.url" + httpretty.register_uri(httpretty.POST, url, body="{}") + result = self.webservice.call( + "post", url=url, headers={"demo_header": "HEADER"} + ) + self.assertEqual(result, b"{}") + self.assertEqual(len(httpretty.latest_requests()), 1) + self.assertEqual( + httpretty.latest_requests()[0].headers["Content-Type"], "application/xml" + ) + self.assertEqual( + httpretty.latest_requests()[0].headers["demo_header"], + "HEADER" + ) + + url = self.url + "custom/path" + self.webservice.url += "{endpoint}" + httpretty.register_uri(httpretty.POST, url, body="{}") + result = self.webservice.call( + "post", + url_params={"endpoint": "custom/path"}, + headers={"demo_header": "HEADER"}, + ) + self.assertEqual(result, b"{}") + self.assertEqual(len(httpretty.latest_requests()), 2) + self.assertEqual( + httpretty.latest_requests()[0].headers["Content-Type"], "application/xml" + ) + self.assertEqual( + httpretty.latest_requests()[0].headers["demo_header"], + "HEADER" + ) diff --git a/webservice/views/webservice_backend.xml b/webservice/views/webservice_backend.xml new file mode 100644 index 00000000..19af3319 --- /dev/null +++ b/webservice/views/webservice_backend.xml @@ -0,0 +1,112 @@ + + + + + + webservice.backend.form (in webservice) + webservice.backend + +
+
+ +
+
+ + + + + + + + + + + + + +
+ + + + + + webservice.backend.search (in webservice) + webservice.backend + + + + + + + + + + + + webservice.backend.tree (in webservice) + webservice.backend + + + + + + + + + + + + + WebService Backend + webservice.backend + tree,form + [] + {} + + + + WebService Backend + + + + + +