[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) <jvm@odoo.com>
This commit is contained in:
Jason Van Malder
2020-01-30 11:59:38 +00:00
parent 2ecbfddd6b
commit f99f4db134
+2 -1
View File
@@ -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):