[MERGE] auth password wizard

bzr revid: al@openerp.com-20121220170950-hyrws7c67qjgpxl5
This commit is contained in:
Antony Lesuisse 2012-12-20 18:09:50 +01:00
commit 6e0cd39df6
2 changed files with 8 additions and 6 deletions

View File

@ -245,11 +245,17 @@ class res_users(osv.Model):
# send email to users with their signup url
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'
for user in self.browse(cr, uid, ids, context):
if not user.email:
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.email)
return True

View File

@ -19,16 +19,12 @@
</header>
</xpath>
<!-- add Reset Password button -->
<xpath expr="//sheet/*[1]" position="before">
<xpath expr="//div[@class='oe_right oe_button_box']" position="replace">
<div class="oe_right oe_button_box">
<button string="Reset Password" type="object" name="action_reset_password"
help="Send an email to the user to (re)set their password."/>
</div>
</xpath>
<!-- hide field set_password -->
<field name="new_password" position="replace">
<field name="new_password" groups="base.group_no_one" password="True"/>
</field>
</field>
</record>