From de8064a2d280854e20d14b5b009f5973e7b47da8 Mon Sep 17 00:00:00 2001 From: Asier Neira Date: Thu, 16 Oct 2025 13:37:31 +0200 Subject: [PATCH] =?UTF-8?q?[FIX]=20fastapi:=20a=C3=B1adir=20compa=C3=B1?= =?UTF-8?q?=C3=ADas=20permitidas=20en=20odoo=5Fenv?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fastapi/dependencies.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/fastapi/dependencies.py b/fastapi/dependencies.py index 47b133285..9bf87970f 100644 --- a/fastapi/dependencies.py +++ b/fastapi/dependencies.py @@ -29,9 +29,12 @@ def company_id() -> int | None: def odoo_env(company_id: Annotated[int | None, Depends(company_id)]) -> Environment: env = odoo_env_ctx.get() - if company_id is not None: - env = env(context=dict(env.context, allowed_company_ids=[company_id])) - + if company_id: + allowed_company_ids = [company_id] + else: + user_id = env["res.users"].browse(env.uid) + allowed_company_ids = user_id.company_ids.ids + env = env(context=dict(env.context, allowed_company_ids=allowed_company_ids)) yield env