From 09a9372c979c632f539805c4a4c6beec13e92567 Mon Sep 17 00:00:00 2001 From: Souheil Bejaoui Date: Thu, 12 Mar 2026 11:54:58 +0100 Subject: [PATCH 1/2] [MIG] fastapi: migration to 19.0 --- .pre-commit-config.yaml | 1 - fastapi/README.rst | 12 ++++++------ fastapi/__manifest__.py | 3 +-- fastapi/demo/fastapi_endpoint_demo.xml | 4 ++-- fastapi/dependencies.py | 4 ++-- fastapi/models/fastapi_endpoint.py | 4 ++-- fastapi/models/fastapi_endpoint_demo.py | 6 +++--- fastapi/readme/USAGE.md | 2 +- fastapi/routers/demo_router.py | 2 +- fastapi/security/res_groups.xml | 10 +++++----- fastapi/static/description/index.html | 8 ++++---- fastapi/tests/common.py | 4 ++-- fastapi/views/fastapi_endpoint.xml | 9 ++------- fastapi/views/fastapi_menu.xml | 2 +- requirements.txt | 7 ------- 15 files changed, 32 insertions(+), 46 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e638ae70e..367dea5f5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,7 +5,6 @@ exclude: | ^base_rest_auth_api_key/| ^base_rest_pydantic/| ^extendable/| - ^fastapi/| ^pydantic/| ^rest_log/| # END NOT INSTALLABLE ADDONS diff --git a/fastapi/README.rst b/fastapi/README.rst index 3fcc9cf45..fd842f62d 100644 --- a/fastapi/README.rst +++ b/fastapi/README.rst @@ -21,13 +21,13 @@ Odoo FastAPI :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html :alt: License: LGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Frest--framework-lightgray.png?logo=github - :target: https://github.com/OCA/rest-framework/tree/18.0/fastapi + :target: https://github.com/OCA/rest-framework/tree/19.0/fastapi :alt: OCA/rest-framework .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/rest-framework-18-0/rest-framework-18-0-fastapi + :target: https://translation.odoo-community.org/projects/rest-framework-19-0/rest-framework-19-0-fastapi :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/rest-framework&target_branch=18.0 + :target: https://runboat.odoo-community.org/builds?repo=OCA/rest-framework&target_branch=19.0 :alt: Try me on Runboat |badge1| |badge2| |badge3| |badge4| |badge5| @@ -449,7 +449,7 @@ handler. .. code:: python - from odoo.addons.base.models.res_partner import Partner + from odoo.addons.base.models.res_partner import ResPartner as Partner @demo_api_router.get("/partners", response_model=list[PartnerInfo]) @@ -1636,7 +1636,7 @@ 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 `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -1674,6 +1674,6 @@ Current `maintainer `__: |maintainer-lmignon| -This module is part of the `OCA/rest-framework `_ project on GitHub. +This module is part of the `OCA/rest-framework `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/fastapi/__manifest__.py b/fastapi/__manifest__.py index 19b719019..5915c68c4 100644 --- a/fastapi/__manifest__.py +++ b/fastapi/__manifest__.py @@ -5,7 +5,7 @@ "name": "Odoo FastAPI", "summary": """ Odoo FastAPI endpoint""", - "version": "18.0.1.3.0", + "version": "19.0.1.3.0", "license": "LGPL-3", "author": "ACSONE SA/NV,Odoo Community Association (OCA)", "maintainers": ["lmignon"], @@ -30,5 +30,4 @@ ] }, "development_status": "Beta", - "installable": False, } diff --git a/fastapi/demo/fastapi_endpoint_demo.xml b/fastapi/demo/fastapi_endpoint_demo.xml index ad94eeaf3..0e1218aa5 100644 --- a/fastapi/demo/fastapi_endpoint_demo.xml +++ b/fastapi/demo/fastapi_endpoint_demo.xml @@ -10,7 +10,7 @@ > My Demo Endpoint User my_demo_app_user - + My Demo Endpoint Group - + diff --git a/fastapi/dependencies.py b/fastapi/dependencies.py index 16226bf29..4471e12ea 100644 --- a/fastapi/dependencies.py +++ b/fastapi/dependencies.py @@ -6,8 +6,8 @@ from odoo.api import Environment from odoo.exceptions import AccessDenied -from odoo.addons.base.models.res_partner import Partner -from odoo.addons.base.models.res_users import Users +from odoo.addons.base.models.res_partner import ResPartner as Partner +from odoo.addons.base.models.res_users import ResUsers as Users from fastapi import Depends, Header, HTTPException, Query, status from fastapi.security import HTTPBasic, HTTPBasicCredentials diff --git a/fastapi/models/fastapi_endpoint.py b/fastapi/models/fastapi_endpoint.py index aed8136de..bf046fc09 100644 --- a/fastapi/models/fastapi_endpoint.py +++ b/fastapi/models/fastapi_endpoint.py @@ -10,7 +10,7 @@ from starlette.middleware import Middleware from starlette.routing import Mount -from odoo import _, api, exceptions, fields, models, tools +from odoo import api, exceptions, fields, models, tools from fastapi import APIRouter, Depends, FastAPI @@ -88,7 +88,7 @@ def _check_root_path(self): for rec in self: if rec.root_path in self._blacklist_root_paths: raise exceptions.UserError( - _( + self.env._( "`%(name)s` uses a blacklisted root_path = `%(root_path)s`", name=rec.name, root_path=rec.root_path, diff --git a/fastapi/models/fastapi_endpoint_demo.py b/fastapi/models/fastapi_endpoint_demo.py index cf3df84c1..0d4eae8bf 100644 --- a/fastapi/models/fastapi_endpoint_demo.py +++ b/fastapi/models/fastapi_endpoint_demo.py @@ -2,11 +2,11 @@ # License LGPL-3.0 or later (http://www.gnu.org/licenses/LGPL). from typing import Annotated, Any -from odoo import _, api, fields, models +from odoo import api, fields, models from odoo.api import Environment from odoo.exceptions import ValidationError -from odoo.addons.base.models.res_partner import Partner +from odoo.addons.base.models.res_partner import ResPartner as Partner from fastapi import APIRouter, Depends, HTTPException, status from fastapi.security import APIKeyHeader @@ -40,7 +40,7 @@ def _valdiate_demo_auth_method(self): for rec in self: if rec.app == "demo" and not rec.demo_auth_method: raise ValidationError( - _( + self.env._( "The authentication method is required for app %(app)s", app=rec.app, ) diff --git a/fastapi/readme/USAGE.md b/fastapi/readme/USAGE.md index 131d7f7b5..3386eccb6 100644 --- a/fastapi/readme/USAGE.md +++ b/fastapi/readme/USAGE.md @@ -360,7 +360,7 @@ When you define a route handler, you can inject the handler. ``` python -from odoo.addons.base.models.res_partner import Partner +from odoo.addons.base.models.res_partner import ResPartner as Partner @demo_api_router.get("/partners", response_model=list[PartnerInfo]) diff --git a/fastapi/routers/demo_router.py b/fastapi/routers/demo_router.py index 36450057a..98633ba6f 100644 --- a/fastapi/routers/demo_router.py +++ b/fastapi/routers/demo_router.py @@ -14,7 +14,7 @@ from odoo.exceptions import AccessError, MissingError, UserError, ValidationError from odoo.service.model import MAX_TRIES_ON_CONCURRENCY_FAILURE -from odoo.addons.base.models.res_partner import Partner +from odoo.addons.base.models.res_partner import ResPartner as Partner from fastapi import APIRouter, Depends, File, HTTPException, Query, status from fastapi.responses import JSONResponse diff --git a/fastapi/security/res_groups.xml b/fastapi/security/res_groups.xml index 589cbcf97..9f699b4bf 100644 --- a/fastapi/security/res_groups.xml +++ b/fastapi/security/res_groups.xml @@ -2,7 +2,7 @@ - + FastAPI Helps you manage your Fastapi Endpoints 99 @@ -11,15 +11,15 @@ User - + Administrator - + @@ -28,6 +28,6 @@ the user running the endpoint handlers and performs authentication --> FastAPI Endpoint Runner - + diff --git a/fastapi/static/description/index.html b/fastapi/static/description/index.html index 2ecae1f73..96e0ed455 100644 --- a/fastapi/static/description/index.html +++ b/fastapi/static/description/index.html @@ -374,7 +374,7 @@

Odoo FastAPI

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! source digest: sha256:ef181029fc269ba5b6364530192a725c5f3392bc026ef9d5fcf47f9e43ec888a !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

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

+

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

This addon provides the basis to smoothly integrate the FastAPI framework into Odoo.

This integration allows you to use all the goodies from @@ -818,7 +818,7 @@

The authentication mechanism< ‘authenticated_partner’ dependency as a parameter of your route handler.

-from odoo.addons.base.models.res_partner import Partner
+from odoo.addons.base.models.res_partner import ResPartner as Partner
 
 
 @demo_api_router.get("/partners", response_model=list[PartnerInfo])
@@ -1937,7 +1937,7 @@ 

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.

+feedback.

Do not contact contributors directly about support or help with technical issues.

@@ -1965,7 +1965,7 @@

Maintainers

promote its widespread use.

Current maintainer:

lmignon

-

This module is part of the OCA/rest-framework project on GitHub.

+

This module is part of the OCA/rest-framework project on GitHub.

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

diff --git a/fastapi/tests/common.py b/fastapi/tests/common.py index f9c05b67e..345e45169 100644 --- a/fastapi/tests/common.py +++ b/fastapi/tests/common.py @@ -14,8 +14,8 @@ from odoo.tests import tagged from odoo.tests.common import TransactionCase -from odoo.addons.base.models.res_partner import Partner -from odoo.addons.base.models.res_users import Users +from odoo.addons.base.models.res_partner import ResPartner as Partner +from odoo.addons.base.models.res_users import ResUsers as Users from fastapi import APIRouter, FastAPI from fastapi.testclient import TestClient diff --git a/fastapi/views/fastapi_endpoint.xml b/fastapi/views/fastapi_endpoint.xml index 77b04fd9b..82df080a7 100644 --- a/fastapi/views/fastapi_endpoint.xml +++ b/fastapi/views/fastapi_endpoint.xml @@ -72,13 +72,8 @@ name="inactive" domain="[('active','=',False)]" /> - - - + + diff --git a/fastapi/views/fastapi_menu.xml b/fastapi/views/fastapi_menu.xml index 90fa87cf1..a3e9a7cfa 100644 --- a/fastapi/views/fastapi_menu.xml +++ b/fastapi/views/fastapi_menu.xml @@ -6,6 +6,6 @@ FastAPI fastapi,static/description/icon.png - + diff --git a/requirements.txt b/requirements.txt index 69f99aad8..bcba9b734 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,13 +1,6 @@ # generated from manifests external_dependencies a2wsgi>=1.10.6 -apispec -cerberus -contextvars -extendable>=0.0.4 fastapi>=0.110.0 parse-accept-language -pydantic>=2.0.0 -pyquerystring python-multipart -typing-extensions ujson From 4e566508d6358edfd17bd4b3157658388d1bc723 Mon Sep 17 00:00:00 2001 From: Souheil Bejaoui Date: Thu, 12 Mar 2026 12:00:01 +0100 Subject: [PATCH 2/2] [DON'T MERGE] add test requirements --- test-requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/test-requirements.txt b/test-requirements.txt index cf108f84e..a79f182c5 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,2 +1,3 @@ odoo_test_helper httpx +odoo-addon-endpoint_route_handler@git+https://github.com/OCA/web-api.git@refs/pull/117/head#subdirectory=endpoint_route_handler