Browse Source

[FIX] 'auth_generate_password' now works even if the password is encrypted in database;

pull/92/head
Sylvain LE GAL 10 years ago
parent
commit
b5274ce45f
  1. 2
      auth_generate_password/data/email_template.xml
  2. 10
      auth_generate_password/model/res_users.py

2
auth_generate_password/data/email_template.xml

@ -31,7 +31,7 @@
Your OpenERP credentials has been changed: Your OpenERP credentials has been changed:
<ul> <ul>
<li>Login : ${object.login}</li> <li>Login : ${object.login}</li>
<li>New Password : ${object.password}</li>
<li>New Password : ${ctx.get('generated_password')}</li>
</ul> </ul>
Please, Please,
<ul> <ul>

10
auth_generate_password/model/res_users.py

@ -34,6 +34,8 @@ class res_users(Model):
_inherit = 'res.users' _inherit = 'res.users'
def generate_password(self, cr, uid, ids, context=None): def generate_password(self, cr, uid, ids, context=None):
if not context:
context = {}
mm_obj = self.pool['mail.mail'] mm_obj = self.pool['mail.mail']
icp_obj = self.pool['ir.config_parameter'] icp_obj = self.pool['ir.config_parameter']
imd_obj = self.pool['ir.model.data'] imd_obj = self.pool['ir.model.data']
@ -42,6 +44,9 @@ class res_users(Model):
cr, uid, 'auth_generate_password.password_size')) cr, uid, 'auth_generate_password.password_size'))
password_chars = eval(icp_obj.get_param( password_chars = eval(icp_obj.get_param(
cr, uid, 'auth_generate_password.password_chars')) cr, uid, 'auth_generate_password.password_chars'))
et = imd_obj.get_object(
cr, uid, 'auth_generate_password', 'generate_password_template')
for ru in self.browse(cr, uid, ids, context=context): for ru in self.browse(cr, uid, ids, context=context):
if not ru.email: if not ru.email:
raise osv.except_osv( raise osv.except_osv(
@ -53,9 +58,8 @@ class res_users(Model):
self._set_new_password( self._set_new_password(
cr, uid, ru.id, None, password, None, context=None) cr, uid, ru.id, None, password, None, context=None)
# Send Mail # Send Mail
et = imd_obj.get_object(
cr, uid, 'auth_generate_password',
'generate_password_template')
context['generated_password'] = password
mail_id = et_obj.send_mail( mail_id = et_obj.send_mail(
cr, uid, et.id, ru.id, True, context=context) cr, uid, et.id, ru.id, True, context=context)
del context['generated_password']
return {} return {}
Loading…
Cancel
Save