Skip to content
Open
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
15 changes: 13 additions & 2 deletions fastapi/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from typing_extensions import Annotated
from typing import TYPE_CHECKING, Optional

from odoo.api import Environment
from odoo.api import Environment, Environments
from odoo.exceptions import AccessDenied

from odoo.addons.base.models.res_partner import Partner
Expand All @@ -25,7 +25,18 @@


def odoo_env() -> Environment:
yield odoo_env_ctx.get()
env = odoo_env_ctx.get()
has_environments = hasattr(env._local, "environments")
if not has_environments:
# in testing mode at update and install the envs is not set
# on the werkzeuk local
envs = Environments()
envs.add(env)
env._local.environments = envs
with Environment.manage():
yield env
else:
yield env

Check warning on line 39 in fastapi/dependencies.py

View check run for this annotation

Codecov / codecov/patch

fastapi/dependencies.py#L39

Added line #L39 was not covered by tests


def authenticated_partner_impl() -> Partner:
Expand Down