diff --git a/fastapi/README.rst b/fastapi/README.rst index 852dd0c52..9f0ba9d26 100644 --- a/fastapi/README.rst +++ b/fastapi/README.rst @@ -7,7 +7,7 @@ Odoo FastAPI !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:439e51bdd708113a0ee8a644f2ca42d29c286af1aee25fa6035b743321969c88 + !! source digest: sha256:de5a0e0642df22387984fd10d2e54007b88126bacdb22e9e8b637c6187abaeeb !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png diff --git a/fastapi/fastapi_dispatcher.py b/fastapi/fastapi_dispatcher.py index 904deeff7..02738b9b1 100644 --- a/fastapi/fastapi_dispatcher.py +++ b/fastapi/fastapi_dispatcher.py @@ -42,8 +42,19 @@ def _make_response(self, status_mapping, headers_tuple, content): self.headers = dict(headers_tuple) def _get_environ(self): - environ = self.request.httprequest.environ - environ["wsgi.input"] = self.request.httprequest._get_stream_for_parsing() + try: + # normal case after + # https://github.com/odoo/odoo/commit/cb1d057dcab28cb0b0487244ba99231ee292502e + httprequest = self.request.httprequest._HTTPRequest__wrapped + except AttributeError: + # fallback for older odoo versions + # The try except is the most efficient way to handle this + # as we expect that most of the time the attribute will be there + # and this code will no more be executed if it runs on an up to + # date odoo version. (EAFP: Easier to Ask for Forgiveness than Permission) + httprequest = self.request.httprequest + environ = httprequest.environ + environ["wsgi.input"] = httprequest._get_stream_for_parsing() return environ @contextmanager diff --git a/fastapi/readme/newsfragments/414.bugfix b/fastapi/readme/newsfragments/414.bugfix new file mode 100644 index 000000000..995a1fc1a --- /dev/null +++ b/fastapi/readme/newsfragments/414.bugfix @@ -0,0 +1,6 @@ +Fix compatibility issues with the latest Odoo version + +From https://github.com/odoo/odoo/commit/cb1d057dcab28cb0b0487244ba99231ee292502e +the original werkzeug HTTPRequest class has been wrapped in a new class to keep +under control the attributes developers use. This changes take care of this +new implementation but also keep compatibility with the old ones. diff --git a/fastapi/static/description/index.html b/fastapi/static/description/index.html index 17469c219..3275f7681 100644 --- a/fastapi/static/description/index.html +++ b/fastapi/static/description/index.html @@ -1,3 +1,4 @@ + @@ -366,7 +367,7 @@

Odoo FastAPI

!! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!! source digest: sha256:439e51bdd708113a0ee8a644f2ca42d29c286af1aee25fa6035b743321969c88 +!! source digest: sha256:de5a0e0642df22387984fd10d2e54007b88126bacdb22e9e8b637c6187abaeeb !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->

Beta License: LGPL-3 OCA/rest-framework Translate me on Weblate Try me on Runboat

This addon provides the basis to smoothly integrate the