From e94d65519da89b8a78019e4804b20ec2e9097742 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Dufays Date: Fri, 2 Sep 2022 15:01:37 +0000 Subject: [PATCH] [FIX] website: fix issue when creating account / relogging When creating an account from the website (through the link "Don't have an account?") while having been previously identified, the creation lasts a very long time and ends-up with a http 502 error (actually a timeout). Same when logging although being already logged. Technical note: The problem was due to a database deadlock because of going twice through authentication. A record was deleted in one transaction while being written in another (_merge_visitor deletes it and _update_visitor_last visit writes it but with different environment). Task-2950241 closes odoo/odoo#99723 Signed-off-by: Thibault Delavallee (tde) --- addons/website/models/res_users.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/website/models/res_users.py b/addons/website/models/res_users.py index 1d582a128de..fe09e066ce5 100644 --- a/addons/website/models/res_users.py +++ b/addons/website/models/res_users.py @@ -81,7 +81,8 @@ class ResUsers(models.Model): if visitor_current_user_sudo: # A visitor exists for the logged in user, link public # visitor records to it. - visitor_pre_authenticate_sudo._merge_visitor(visitor_current_user_sudo) + if visitor_pre_authenticate_sudo != visitor_current_user_sudo: + visitor_pre_authenticate_sudo._merge_visitor(visitor_current_user_sudo) visitor_current_user_sudo._update_visitor_last_visit() else: visitor_pre_authenticate_sudo.access_token = user_partner.id