From 97bf527aa46483ddcfa1c3e2144829b0768fb1a9 Mon Sep 17 00:00:00 2001 From: "vta vta@openerp.com" <> Date: Wed, 19 Dec 2012 16:49:57 +0100 Subject: [PATCH] [ADD] Added change_password_wizard bzr revid: vta@openerp.com-20121219154957-bf65kkqpikbwyua1 --- openerp/addons/base/__openerp__.py | 1 + openerp/addons/base/res/__init__.py | 5 +- openerp/addons/base/res/wizard/__init__.py | 22 ++++++ .../base/res/wizard/change_password_wizard.py | 70 +++++++++++++++++++ .../wizard/change_password_wizard_view.xml | 47 +++++++++++++ 5 files changed, 143 insertions(+), 2 deletions(-) create mode 100644 openerp/addons/base/res/wizard/__init__.py create mode 100644 openerp/addons/base/res/wizard/change_password_wizard.py create mode 100644 openerp/addons/base/res/wizard/change_password_wizard_view.xml diff --git a/openerp/addons/base/__openerp__.py b/openerp/addons/base/__openerp__.py index b4473434cdf..d0a1e37e3e2 100644 --- a/openerp/addons/base/__openerp__.py +++ b/openerp/addons/base/__openerp__.py @@ -83,6 +83,7 @@ The kernel of OpenERP, needed for all installation. 'res/res_users_view.xml', 'res/res_partner_data.xml', 'res/ir_property_view.xml', + 'res/wizard/change_password_wizard_view.xml', 'security/base_security.xml', 'security/ir.model.access.csv', ], diff --git a/openerp/addons/base/res/__init__.py b/openerp/addons/base/res/__init__.py index 752bb03033a..59403545112 100644 --- a/openerp/addons/base/res/__init__.py +++ b/openerp/addons/base/res/__init__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (). # @@ -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 . +# along with this program. If not, see . # ############################################################################## @@ -32,6 +32,7 @@ import res_lang import ir_property import report +import wizard # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/openerp/addons/base/res/wizard/__init__.py b/openerp/addons/base/res/wizard/__init__.py new file mode 100644 index 00000000000..f572814a2cf --- /dev/null +++ b/openerp/addons/base/res/wizard/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2011 OpenERP S.A (). +# +# 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 . +# +############################################################################## + +import change_password_wizard \ No newline at end of file diff --git a/openerp/addons/base/res/wizard/change_password_wizard.py b/openerp/addons/base/res/wizard/change_password_wizard.py new file mode 100644 index 00000000000..fc3946897b8 --- /dev/null +++ b/openerp/addons/base/res/wizard/change_password_wizard.py @@ -0,0 +1,70 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2011 OpenERP S.A (). +# +# 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 . +# +############################################################################## + +from openerp.osv import fields, osv + +class change_password_wizard(osv.TransientModel): + """ + A wizard to manage the change of users' passwords + """ + def _get_user_ids(self, cr, uid, context=None): + if context == None: + context = {} + return context.get('active_ids', []) + + _name = "change.password.wizard" + _description = "Change Password Wizard" + _columns = { + 'user_ids': fields.one2many('change.password.user', 'wizard_id', string='Users'), + } + _defaults = { + 'user_ids': _get_user_ids, + } + + def change_password_button(self, cr, uid, ids, context=None): + user_ids = self.browse(cr, uid, ids[0], context=context).user_ids + 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), + 'login': fields.related('user_id', 'login', type='char', relation='res.users', string='User Login', readonly=True), + 'new_passwd': fields.char('New Password', required=True), + 'old_passwd': fields.related('user_id', 'password', type='char', relation='res.users', string='Old Password', readonly=True) + } + _defaults = { + } + + 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').change_password(cr, uid, user.old_passwd, user.new_passwd, context=context) diff --git a/openerp/addons/base/res/wizard/change_password_wizard_view.xml b/openerp/addons/base/res/wizard/change_password_wizard_view.xml new file mode 100644 index 00000000000..af4488a9634 --- /dev/null +++ b/openerp/addons/base/res/wizard/change_password_wizard_view.xml @@ -0,0 +1,47 @@ + + + + + + + + + + Change Password + change.password.wizard + +
+
+ You can change the password of the following users: +
+ +
+
+ +
+
+ + + + Change Password Users + change.password.user + + + + + + + + + +
+