[MERGE] auth password wizard

bzr revid: al@openerp.com-20121220171038-y0s6bhfhbp81pbmz
This commit is contained in:
Antony Lesuisse 2012-12-20 18:10:38 +01:00
commit 7b80e60135
6 changed files with 155 additions and 3 deletions

View File

@ -80,6 +80,7 @@ The kernel of OpenERP, needed for all installation.
'res/res_bank_view.xml',
'res/res_country_view.xml',
'res/res_currency_view.xml',
'res/wizard/change_password_wizard_view.xml',
'res/res_users_view.xml',
'res/res_partner_data.xml',
'res/ir_property_view.xml',

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
#
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
#
@ -15,7 +15,7 @@
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
@ -32,6 +32,7 @@ import res_lang
import ir_property
import report
import wizard
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -136,6 +136,10 @@
<form string="Users" version="7.0">
<field name="id" invisible="1"/>
<sheet>
<div class="oe_right oe_button_box">
<button string="Change Password" type="action" name="%(change_password_wizard_action)d"
help="Change the user password."/>
</div>
<field name="image" widget='image' class="oe_avatar oe_left" options='{"preview_image": "image_medium"}'/>
<div class="oe_title">
<label for="name" class="oe_edit_only"/>
@ -145,7 +149,6 @@
</div>
<group>
<group>
<field name="new_password" password="True" attrs="{'required': [('id','=',False)]}"/>
<field name="company_id" context="{'user_preference': 0}"/>
</group>
<group>

View File

@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2011 OpenERP S.A (<http://www.openerp.com>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import change_password_wizard

View File

@ -0,0 +1,81 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2011 OpenERP S.A (<http://www.openerp.com>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp.osv import fields, osv
class change_password_wizard(osv.TransientModel):
"""
A wizard to manage the change of users' passwords
"""
_name = "change.password.wizard"
_description = "Change Password Wizard"
_columns = {
'user_ids': fields.one2many('change.password.user', 'wizard_id', string='Users'),
}
def default_get(self, cr, uid, fields, context=None):
if context == None:
context = {}
user_ids = context.get('active_ids', [])
wiz_id = context.get('active_id', None)
res = []
users = self.pool.get('res.users').browse(cr, uid, user_ids, context=context)
for user in users:
res.append((0, 0, {
'wizard_id': wiz_id,
'user_id': user.id,
'user_login': user.login,
}))
return {'user_ids': res}
def change_password_button(self, cr, uid, id, context=None):
wizard = self.browse(cr, uid, id, context=context)[0]
user_ids = []
for user in wizard.user_ids:
user_ids.append(user.id)
self.pool.get('change.password.user').change_password_button(cr, uid, user_ids, context=context)
return {
'type': 'ir.actions.act_window_close',
}
class change_password_user(osv.TransientModel):
"""
A model to configure users in the change password wizard
"""
_name = 'change.password.user'
_description = 'Change Password Wizard User'
_columns = {
'wizard_id': fields.many2one('change.password.wizard', string='Wizard', required=True),
'user_id': fields.many2one('res.users', string='User', required=True),
'user_login': fields.char('User Login', readonly=True),
'new_passwd': fields.char('New Password'),
}
_defaults = {
'new_passwd': '',
}
def change_password_button(self, cr, uid, ids, context=None):
for user in self.browse(cr, uid, ids, context=context):
self.pool.get('res.users').write(cr, uid, user.user_id.id, {'password': user.new_passwd})

View File

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!-- wizard action on res.users -->
<act_window id="change_password_wizard_action"
name="Change Password"
src_model="res.users"
res_model="change.password.wizard"
view_type="form" view_mode="form"
key2="client_action_multi" target="new"
groups="base.group_erp_manager"/>
<!-- wizard view -->
<record id="change_password_wizard_view" model="ir.ui.view">
<field name="name">Change Password</field>
<field name="model">change.password.wizard</field>
<field name="arch" type="xml">
<form string="Change Password" version="7.0">
<field name="user_ids"/>
<footer>
<button string="Change Password" name="change_password_button" type="object" class="oe_highlight"/>
or
<button string="Cancel" class="oe_link" special="cancel" />
</footer>
</form>
</field>
</record>
<!-- wizard user list view -->
<record id="change_password_wizard_user_tree_view" model="ir.ui.view">
<field name="name">Change Password Users</field>
<field name="model">change.password.user</field>
<field name="arch" type="xml">
<!-- the user list is editable, but one cannot add or delete rows -->
<tree string="Users" editable="bottom" create="false" delete="false">
<field name="user_login"/>
<field name="new_passwd" required="True"/>
</tree>
</field>
</record>
</data>
</openerp>