From 7c125b4176c9945a7e2ded926dfafccedf2f0b3f Mon Sep 17 00:00:00 2001 From: Zina Rasoamanana Date: Fri, 12 Jan 2024 15:34:25 +0100 Subject: [PATCH] [16.0][FIX] fastapi: always add authenticate_partner_id in context when evaluating ir rules This fix is needed since a modificiation of ir.rule that checks the domain when creating/modifying ir rules The solution is to set authenticate_partner_id to False when it is not present in context --- fastapi/README.rst | 2 +- fastapi/fastapi_dispatcher.py | 4 ---- fastapi/models/ir_rule.py | 7 +++---- fastapi/readme/newsfragments/410.bugfix | 5 +++++ fastapi/static/description/index.html | 3 ++- 5 files changed, 11 insertions(+), 10 deletions(-) create mode 100644 fastapi/readme/newsfragments/410.bugfix diff --git a/fastapi/README.rst b/fastapi/README.rst index 44a1d81b..37236f98 100644 --- a/fastapi/README.rst +++ b/fastapi/README.rst @@ -7,7 +7,7 @@ Odoo FastAPI !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:2b79ba7bbc412d35210ba755b9fca17352faad894aa88c9339fb7063d02a50bf + !! source digest: sha256:8a90dec844eac96b44cefb64548fb05283ade12b16246bb89062abc7644e2087 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png diff --git a/fastapi/fastapi_dispatcher.py b/fastapi/fastapi_dispatcher.py index a78e3f81..904deeff 100644 --- a/fastapi/fastapi_dispatcher.py +++ b/fastapi/fastapi_dispatcher.py @@ -49,10 +49,6 @@ def _get_environ(self): @contextmanager def _manage_odoo_env(self, uid=None): env = request.env - # add authenticated_partner_id=False in the context - # to ensure that the ir.rule defined for user's endpoint can be - # evaluated even if not authenticated partner is set - env = env(context=dict(env.context, authenticated_partner_id=False)) accept_language = request.httprequest.headers.get("Accept-language") context = env.context if accept_language: diff --git a/fastapi/models/ir_rule.py b/fastapi/models/ir_rule.py index b1d10fc5..68bda16f 100644 --- a/fastapi/models/ir_rule.py +++ b/fastapi/models/ir_rule.py @@ -17,10 +17,9 @@ class IrRule(models.Model): @api.model def _eval_context(self): ctx = super()._eval_context() - if "authenticated_partner_id" in self.env.context: - ctx["authenticated_partner_id"] = self.env.context[ - "authenticated_partner_id" - ] + ctx["authenticated_partner_id"] = self.env.context.get( + "authenticated_partner_id", False + ) return ctx def _compute_domain_keys(self): diff --git a/fastapi/readme/newsfragments/410.bugfix b/fastapi/readme/newsfragments/410.bugfix new file mode 100644 index 00000000..23ad39e2 --- /dev/null +++ b/fastapi/readme/newsfragments/410.bugfix @@ -0,0 +1,5 @@ +Odoo has done an update and now, it checks domains of ir.rule on creation and modification. + +The ir.rule 'Fastapi: Running user rule' uses a field (authenticate_partner_id) that comes from the context. +This field wasn't always set and this caused an error when Odoo checked the domain. +So now it is set to *False* by default. diff --git a/fastapi/static/description/index.html b/fastapi/static/description/index.html index 1a75628e..a1c84d0a 100644 --- a/fastapi/static/description/index.html +++ b/fastapi/static/description/index.html @@ -1,3 +1,4 @@ + @@ -366,7 +367,7 @@

Odoo FastAPI

!! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!! source digest: sha256:2b79ba7bbc412d35210ba755b9fca17352faad894aa88c9339fb7063d02a50bf +!! source digest: sha256:8a90dec844eac96b44cefb64548fb05283ade12b16246bb89062abc7644e2087 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->

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