From b4a60cfcc5bd0ef3ac50bad88a7489cb3daa4cf6 Mon Sep 17 00:00:00 2001 From: Thibault Francois Date: Thu, 16 Feb 2023 13:17:34 +0000 Subject: [PATCH] [FIX] mail,phone_validation: blacklist email prior deactivation Before this commit, the email added to the blacklist was the value of the email after the deactivation of the user. It may lead to blacklist the wrong email when the deactivation change the email after this commit, like phone number, we keep the value of the email prior the deactivation which the real email to blacklist closes odoo/odoo#113187 X-original-commit: db85db81df57da87c57171fa2d5009eb097f2903 Signed-off-by: Thibault Delavallee (tde) --- addons/mail/models/res_users.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/mail/models/res_users.py b/addons/mail/models/res_users.py index 469b996ca19..30b44080ebb 100644 --- a/addons/mail/models/res_users.py +++ b/addons/mail/models/res_users.py @@ -277,16 +277,16 @@ class Users(models.Model): ) if post.get('request_blacklist'): - users_to_blacklist = self.filtered( - lambda user: tools.email_normalize(user.email)) + users_to_blacklist = [(user, user.email) for user in self.filtered( + lambda user: tools.email_normalize(user.email))] else: users_to_blacklist = [] super(Users, self)._deactivate_portal_user(**post) - for user in users_to_blacklist: + for user, user_email in users_to_blacklist: self.env['mail.blacklist']._add( - user.email, + user_email, message=_('Blocked by deletion of portal account %(portal_user_name)s by %(user_name)s (#%(user_id)s)', user_name=current_user.name, user_id=current_user.id, portal_user_name=user.name)