[IMP] Show alert when sending a mail to reset password (or failure)
bzr revid: vta@openerp.com-20121220141151-z3hd9i95eydd6l1h
This commit is contained in:
parent
1921725d7f
commit
5d729481de
|
@ -245,11 +245,17 @@ class res_users(osv.Model):
|
||||||
|
|
||||||
# send email to users with their signup url
|
# send email to users with their signup url
|
||||||
template = self.pool.get('ir.model.data').get_object(cr, uid, 'auth_signup', 'reset_password_email')
|
template = self.pool.get('ir.model.data').get_object(cr, uid, 'auth_signup', 'reset_password_email')
|
||||||
|
mail_obj = self.pool.get('mail.mail')
|
||||||
assert template._name == 'email.template'
|
assert template._name == 'email.template'
|
||||||
for user in self.browse(cr, uid, ids, context):
|
for user in self.browse(cr, uid, ids, context):
|
||||||
if not user.email:
|
if not user.email:
|
||||||
raise osv.except_osv(_("Cannot send email: user has no email address."), user.name)
|
raise osv.except_osv(_("Cannot send email: user has no email address."), user.name)
|
||||||
self.pool.get('email.template').send_mail(cr, uid, template.id, user.id, True, context=context)
|
mail_id = self.pool.get('email.template').send_mail(cr, uid, template.id, user.id, True, context=context)
|
||||||
|
mail_state = mail_obj.read(cr, uid, mail_id, ['state'], context=context)
|
||||||
|
if mail_state and mail_state == 'exception':
|
||||||
|
raise osv.except_osv(_("Cannot send email: no outgoing email server configured.\nYou can configure it under Settings/General Settings."), user.name)
|
||||||
|
else:
|
||||||
|
raise osv.except_osv(_("Mail sent to user:"), user.name)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue