[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) <tde@openerp.com>
This commit is contained in:
Thibault Francois
2023-02-21 11:25:45 +01:00
parent 354d311b3c
commit b4a60cfcc5
+4 -4
View File
@@ -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)