Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ exclude: |
^base_rest_auth_api_key/|
^base_rest_pydantic/|
^extendable/|
^fastapi/|
^pydantic/|
^rest_log/|
# END NOT INSTALLABLE ADDONS
Expand Down
12 changes: 6 additions & 6 deletions fastapi/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down Expand Up @@ -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])
Expand Down Expand Up @@ -1636,7 +1636,7 @@ 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:%20fastapi%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/rest-framework/issues/new?body=module:%20fastapi%0Aversion:%2019.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.

Expand Down Expand Up @@ -1674,6 +1674,6 @@ 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/fastapi>`_ project on GitHub.
This module is part of the `OCA/rest-framework <https://github.com/OCA/rest-framework/tree/19.0/fastapi>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
3 changes: 1 addition & 2 deletions fastapi/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand All @@ -30,5 +30,4 @@
]
},
"development_status": "Beta",
"installable": False,
}
4 changes: 2 additions & 2 deletions fastapi/demo/fastapi_endpoint_demo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
>
<field name="name">My Demo Endpoint User</field>
<field name="login">my_demo_app_user</field>
<field name="groups_id" eval="[(6, 0, [])]" />
<field name="group_ids" eval="[(6, 0, [])]" />
</record>

<!-- This is the group that will be used to run the demo app
Expand All @@ -20,7 +20,7 @@
-->
<record id="my_demo_app_group" model="res.groups">
<field name="name">My Demo Endpoint Group</field>
<field name="users" eval="[(4, ref('my_demo_app_user'))]" />
<field name="user_ids" eval="[(4, ref('my_demo_app_user'))]" />
<field name="implied_ids" eval="[(4, ref('group_fastapi_endpoint_runner'))]" />
</record>

Expand Down
4 changes: 2 additions & 2 deletions fastapi/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions fastapi/models/fastapi_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions fastapi/models/fastapi_endpoint_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
)
Expand Down
2 changes: 1 addition & 1 deletion fastapi/readme/USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
2 changes: 1 addition & 1 deletion fastapi/routers/demo_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions fastapi/security/res_groups.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!-- Copyright 2022 ACSONE SA/NV
License LGPL-3.0 or later (http://www.gnu.org/licenses/LGPL). -->
<odoo>
<record model="ir.module.category" id="module_category_fastapi">
<record model="res.groups.privilege" id="module_category_fastapi">
<field name="name">FastAPI</field>
<field name="description">Helps you manage your Fastapi Endpoints</field>
<field name="sequence">99</field>
Expand All @@ -11,15 +11,15 @@
<record id="group_fastapi_user" model="res.groups">
<field name="name">User</field>
<field name="implied_ids" eval="[(4, ref('base.group_user'))]" />
<field name="category_id" ref="module_category_fastapi" />
<field name="privilege_id" ref="module_category_fastapi" />
</record>

<record id="group_fastapi_manager" model="res.groups">
<field name="name">Administrator</field>
<field name="category_id" ref="module_category_fastapi" />
<field name="privilege_id" ref="module_category_fastapi" />
<field name="implied_ids" eval="[(4, ref('group_fastapi_user'))]" />
<field
name="users"
name="user_ids"
eval="[(4, ref('base.user_root')), (4, ref('base.user_admin'))]"
/>
</record>
Expand All @@ -28,6 +28,6 @@
the user running the endpoint handlers and performs authentication -->
<record id="group_fastapi_endpoint_runner" model="res.groups">
<field name="name">FastAPI Endpoint Runner</field>
<field name="category_id" ref="module_category_fastapi" />
<field name="privilege_id" ref="module_category_fastapi" />
</record>
</odoo>
8 changes: 4 additions & 4 deletions fastapi/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ <h1>Odoo FastAPI</h1>
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:ef181029fc269ba5b6364530192a725c5f3392bc026ef9d5fcf47f9e43ec888a
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/license-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/rest-framework/tree/18.0/fastapi"><img alt="OCA/rest-framework" src="https://img.shields.io/badge/github-OCA%2Frest--framework-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/rest-framework-18-0/rest-framework-18-0-fastapi"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/rest-framework&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/license-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/rest-framework/tree/19.0/fastapi"><img alt="OCA/rest-framework" src="https://img.shields.io/badge/github-OCA%2Frest--framework-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/rest-framework-19-0/rest-framework-19-0-fastapi"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/rest-framework&amp;target_branch=19.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This addon provides the basis to smoothly integrate the
<a class="reference external" href="https://fastapi.tiangolo.com/">FastAPI</a> framework into Odoo.</p>
<p>This integration allows you to use all the goodies from
Expand Down Expand Up @@ -818,7 +818,7 @@ <h3><a class="toc-backref" href="#toc-entry-5">The authentication mechanism</a><
<strong>‘authenticated_partner’</strong> dependency as a parameter of your route
handler.</p>
<pre class="code python literal-block">
<span class="kn">from</span><span class="w"> </span><span class="nn">odoo.addons.base.models.res_partner</span><span class="w"> </span><span class="kn">import</span> <span class="n">Partner</span><span class="w">
<span class="kn">from</span><span class="w"> </span><span class="nn">odoo.addons.base.models.res_partner</span><span class="w"> </span><span class="kn">import</span> <span class="n">ResPartner</span> <span class="k">as</span> <span class="n">Partner</span><span class="w">


</span><span class="nd">&#64;demo_api_router</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;/partners&quot;</span><span class="p">,</span> <span class="n">response_model</span><span class="o">=</span><span class="nb">list</span><span class="p">[</span><span class="n">PartnerInfo</span><span class="p">])</span><span class="w">
Expand Down Expand Up @@ -1937,7 +1937,7 @@ <h2><a class="toc-backref" href="#toc-entry-40">Bug Tracker</a></h2>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/rest-framework/issues">GitHub Issues</a>.
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
<a class="reference external" href="https://github.com/OCA/rest-framework/issues/new?body=module:%20fastapi%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/rest-framework/issues/new?body=module:%20fastapi%0Aversion:%2019.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
Expand Down Expand Up @@ -1965,7 +1965,7 @@ <h3><a class="toc-backref" href="#toc-entry-44">Maintainers</a></h3>
promote its widespread use.</p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
<p><a class="reference external image-reference" href="https://github.com/lmignon"><img alt="lmignon" src="https://github.com/lmignon.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/rest-framework/tree/18.0/fastapi">OCA/rest-framework</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/rest-framework/tree/19.0/fastapi">OCA/rest-framework</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions fastapi/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 2 additions & 7 deletions fastapi/views/fastapi_endpoint.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,8 @@
name="inactive"
domain="[('active','=',False)]"
/>
<group expand='0' string='Group by...'>
<filter
string='App'
name="groupby_app"
context="{'group_by': 'app'}"
/>
</group>
<separator />
<filter string='App' name="groupby_app" context="{'group_by': 'app'}" />
</search>
</field>
</record>
Expand Down
2 changes: 1 addition & 1 deletion fastapi/views/fastapi_menu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
<field name="name">FastAPI</field>
<field name="sequence" eval="400" />
<field name="web_icon">fastapi,static/description/icon.png</field>
<field name="groups_id" eval="[(4, ref('group_fastapi_user'))]" />
<field name="group_ids" eval="[(4, ref('group_fastapi_user'))]" />
</record>
</odoo>
7 changes: 0 additions & 7 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions test-requirements.txt
Original file line number Diff line number Diff line change
@@ -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
Loading