Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
a126586
[ADD] extendable_fastapi: New addon to allow the use of extendable wi…
lmignon Feb 24, 2023
ce76b55
[IMP] extendable_fastapi: Relicence to lgpl
lmignon Feb 26, 2023
dedf2fd
[IMP] extendable_fastapi: Ensure extended pydantic models are working
lmignon Feb 27, 2023
4b51c4b
Fix schema generation
lmignon Jun 7, 2023
52b4f4a
[UPD] Update extendable_fastapi.pot
Jun 7, 2023
12b41a6
[IMP] extendable_fastapi: Add class to ease tests with fastapi and ex…
lmignon Jun 26, 2023
ac6b336
extendable_fastapi 16.0.1.0.1
OCA-git-bot Jun 28, 2023
0eac514
Migration to Pydantic v2
lmignon Jul 24, 2023
78433fb
[UPD] Update extendable_fastapi.pot
Jul 25, 2023
5f6e695
[ADD] extendable_fastapi: New class StrictExtendableBaseModel
marielejeune Jul 28, 2023
2c3175b
extendable_fastapi 16.0.2.0.1
OCA-git-bot Aug 1, 2023
03c0b96
[RMV] test_extendable_pydantic_fastapi: move tests to extendable_fastapi
marielejeune Aug 1, 2023
1e5d2e5
[IMP] extendable_fastapi unit tests: use ExtendableBaseModel
marielejeune Aug 1, 2023
4e21a20
[UPD] extendable_fastapi: add unit test
marielejeune Aug 1, 2023
44f2256
[UPD] README.rst
OCA-git-bot Aug 1, 2023
26117fa
[FIX] extendable_fastapi: Coercion must be possible
lmignon Sep 19, 2023
c3a3db1
oca-github-bot post-merge updates
OCA-git-bot Sep 19, 2023
6cedb58
[IMP] extendable_fastapi: Add PagedCollection schema
lmignon Oct 11, 2023
8d8a28d
[BOT] post-merge updates
OCA-git-bot Oct 13, 2023
3d41841
[FIX] extendable_fastapi: Registry corruption in tests
lmignon Nov 7, 2023
e23ddd3
[BOT] post-merge updates
OCA-git-bot Nov 7, 2023
880b515
[MIG] mark all modules installable=False
sbidoul Nov 12, 2023
c142bd9
[IMP] extendable_fastapi: pre-commit auto fixes
grindtildeath Jun 13, 2025
05ee2e6
[MIG] extendable_fastapi: Migration to 18.0
grindtildeath Jun 13, 2025
ed93b30
Merge branch '18.0' into 18.0-mig-extendable_fastapi
lmignon Oct 20, 2025
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
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
exclude: |
(?x)
# NOT INSTALLABLE ADDONS
^extendable/|
^extendable_fastapi/|
# END NOT INSTALLABLE ADDONS
# Files and folders generated by bots, to avoid loops
^setup/|/static/description/index\.html$|
Expand Down
1 change: 0 additions & 1 deletion extendable/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

from contextlib import contextmanager

import odoo
from odoo import SUPERUSER_ID, api
from odoo.modules.registry import Registry
from odoo.tests import common
Expand Down
119 changes: 119 additions & 0 deletions extendable_fastapi/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
==================
Extendable Fastapi
==================

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

.. |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-LGPL--3-blue.png
: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/extendable_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-extendable_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
:alt: Try me on Runboat

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

This addon is a technical addon used to allows the use of
`extendable <https://pypi.org/project/extendable/>`__ classes in the
implementation of your fastapi endpoint handlers. It also allows you to
use
`extendable_pydantic <https://pypi.org/project/extendable_pydantic/>`__
models when defining your endpoint handlers request and response models.

**Table of contents**

.. contents::
:local:

Changelog
=========

16.0.2.1.1 (2023-11-07)
-----------------------

**Bugfixes**

- Fix registry corruption when running tests difined in a class
inheriting of the *FastAPITransactionCase* class if an error occurs
in the *setUpClass* after the call to super().
(`#392 <https://github.com/OCA/rest-framework/issues/392>`__)

16.0.2.1.0 (2023-10-13)
-----------------------

**Features**

-

- New base schemas: *PagedCollection*. This schema is used to define
the the structure of a paged collection of resources. This schema
is similar to the ones defined in the Odoo's **fastapi** addon but
works as/with extendable models.
- The *StrictExtendableBaseModel* has been moved to the
*extendable_pydantic* python lib. You should consider to import it
from there.
(`#380 <https://github.com/OCA/rest-framework/issues/380>`__)

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/rest-framework/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/rest-framework/issues/new?body=module:%20extendable_fastapi%0Aversion:%2018.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
-------

* ACSONE SA/NV

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

- Laurent Mignon <laurent.mignon@acsone.eu> (https://acsone.eu)
- Marie Lejeune <marie.lejeune@acsone.eu> (https://acsone.eu)

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-lmignon| image:: https://github.com/lmignon.png?size=40px
:target: https://github.com/lmignon
:alt: lmignon

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

|maintainer-lmignon|

This module is part of the `OCA/rest-framework <https://github.com/OCA/rest-framework/tree/18.0/extendable_fastapi>`_ 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 extendable_fastapi/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import fastapi_dispatcher
from .schemas import StrictExtendableBaseModel
23 changes: 23 additions & 0 deletions extendable_fastapi/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright 2023 ACSONE SA/NV
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).

{
"name": "Extendable Fastapi",
"summary": """
Allows the use of extendable into fastapi apps""",
"version": "18.0.1.0.0",
"license": "LGPL-3",
"author": "ACSONE SA/NV,Odoo Community Association (OCA)",
"maintainers": ["lmignon"],
"website": "https://github.com/OCA/rest-framework",
"depends": ["fastapi", "extendable"],
"data": [],
"demo": [],
"external_dependencies": {
"python": [
"pydantic>=2.0.0",
"extendable-pydantic>=1.2.0",
],
},
"installable": True,
}
30 changes: 30 additions & 0 deletions extendable_fastapi/fastapi_dispatcher.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright 2023 ACSONE SA/NV
# License LGPL-3.0 or later (http://www.gnu.org/licenses/LGPL).

from contextlib import contextmanager

from odoo.addons.extendable.registry import _extendable_registries_database
from odoo.addons.fastapi.fastapi_dispatcher import (
FastApiDispatcher as BaseFastApiDispatcher,
)

from extendable import context


class FastApiDispatcher(BaseFastApiDispatcher):
routing_type = "fastapi"

def dispatch(self, endpoint, args):
with self._manage_extendable_context():
return super().dispatch(endpoint, args)

@contextmanager
def _manage_extendable_context(self):
env = self.request.env
registry = _extendable_registries_database.get(env.cr.dbname, {})
token = context.extendable_registry.set(registry)
try:
response = yield
finally:
context.extendable_registry.reset(token)
return response
13 changes: 13 additions & 0 deletions extendable_fastapi/i18n/extendable_fastapi.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
#
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"
1 change: 1 addition & 0 deletions extendable_fastapi/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import fastapi_endpoint_demo
19 changes: 19 additions & 0 deletions extendable_fastapi/models/fastapi_endpoint_demo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2023 ACSONE SA/NV
# License LGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import models

from fastapi import APIRouter

from ..tests.routers import demo_pydantic_router


class FastapiEndpoint(models.Model):
_inherit = "fastapi.endpoint"

def _get_fastapi_routers(self) -> list[APIRouter]:
# Add router defined for tests to the demo app
routers = super()._get_fastapi_routers()
if self.app == "demo":
routers.append(demo_pydantic_router)
return routers
3 changes: 3 additions & 0 deletions extendable_fastapi/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
2 changes: 2 additions & 0 deletions extendable_fastapi/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Laurent Mignon \<<laurent.mignon@acsone.eu>\> (<https://acsone.eu>)
- Marie Lejeune \<<marie.lejeune@acsone.eu>\> (<https://acsone.eu>)
5 changes: 5 additions & 0 deletions extendable_fastapi/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
This addon is a technical addon used to allows the use of
[extendable](https://pypi.org/project/extendable/) classes in the
implementation of your fastapi endpoint handlers. It also allows you to
use [extendable_pydantic](https://pypi.org/project/extendable_pydantic/)
models when defining your endpoint handlers request and response models.
21 changes: 21 additions & 0 deletions extendable_fastapi/readme/HISTORY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
## 16.0.2.1.1 (2023-11-07)

**Bugfixes**

- Fix registry corruption when running tests difined in a class
inheriting of the *FastAPITransactionCase* class if an error occurs in
the *setUpClass* after the call to super().
([\#392](https://github.com/OCA/rest-framework/issues/392))

## 16.0.2.1.0 (2023-10-13)

**Features**

- - New base schemas: *PagedCollection*. This schema is used to define
the the structure of a paged collection of resources. This schema is
similar to the ones defined in the Odoo's **fastapi** addon but
works as/with extendable models.
- The *StrictExtendableBaseModel* has been moved to the
*extendable_pydantic* python lib. You should consider to import it
from there.
([\#380](https://github.com/OCA/rest-framework/issues/380))
Empty file.
19 changes: 19 additions & 0 deletions extendable_fastapi/schemas.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from typing import Annotated, Generic, TypeVar

from extendable_pydantic import StrictExtendableBaseModel

from pydantic import Field

T = TypeVar("T")


class PagedCollection(StrictExtendableBaseModel, Generic[T]):
"""A paged collection of items"""

# This is a generic model. The type of the items is defined by the generic type T.
# It provides you a common way to return a paged collection of items of
# extendable models. It's based on the StrictExtendableBaseModel to ensure
# a strict validation when used within the odoo fastapi framework.

count: Annotated[int, Field(..., description="The count of items into the system")]
items: list[T]
Binary file added extendable_fastapi/static/description/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading