From 156e2f1fc3f565355ef8334488eaee31adb4d4a7 Mon Sep 17 00:00:00 2001 From: "Nasreddin Boulif (bon)" Date: Tue, 30 Aug 2022 04:35:51 +0000 Subject: [PATCH] [FIX] website: get right access token for public visitor user Current Behavior: When we get the access token for a website visitor, we check if the `self.env.user` is a public user. If it is, we return his id. Expected behavior: We should check the `request.env.user` instead since the visitor can only be created through the frontend. opw-2956186 Part-of: odoo/odoo#99181 --- addons/website/models/website_visitor.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/website/models/website_visitor.py b/addons/website/models/website_visitor.py index e70ba1b8514..cee5bd460a4 100644 --- a/addons/website/models/website_visitor.py +++ b/addons/website/models/website_visitor.py @@ -37,8 +37,8 @@ class WebsiteVisitor(models.Model): if not request: raise ValueError("Visitors can only be created through the frontend.") - if not self.env.user._is_public(): - return self.env.user.partner_id.id + if not request.env.user._is_public(): + return request.env.user.partner_id.id msg = repr(( request.httprequest.remote_addr,