From f99f4db134fae2d22ec3cc1cf98b189e253bd4c3 Mon Sep 17 00:00:00 2001 From: Jason Van Malder Date: Wed, 22 Jan 2020 09:59:29 +0000 Subject: [PATCH] [FIX] auth_signup: fix email sent when testing an import Issue - Contacts - Import a contact that will be a portal user - Test import Activation email sent Cause Testing an import do the whole process including sending an email because of force_send (email not rollbacked). Solution Check if we are testing the import. If yes, do not force send the email. So, the email will be rollbacked. OPW-2168868 closes odoo/odoo#44283 X-original-commit: f372334facd189d0a70268e7876511bf1f800a4a Signed-off-by: Jason Van Malder (jvm) --- addons/auth_signup/models/res_users.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/auth_signup/models/res_users.py b/addons/auth_signup/models/res_users.py index a1abd1c32b6..dc7d15f2997 100644 --- a/addons/auth_signup/models/res_users.py +++ b/addons/auth_signup/models/res_users.py @@ -197,7 +197,8 @@ class ResUsers(models.Model): raise UserError(_("Cannot send email: user %s has no email address.") % user.name) # TDE FIXME: make this template technical (qweb) with self.env.cr.savepoint(): - template.send_mail(user.id, force_send=True, raise_exception=True) + force_send = not(self.env.context.get('import_file', False)) + template.send_mail(user.id, force_send=force_send, raise_exception=True) _logger.info("Password reset email sent for user <%s> to <%s>", user.login, user.email) def send_unregistered_user_reminder(self, after_days=5):