nch(OpenERP) has proposed merging 
lp:~openerp-commiter/openobject-client/passwd_change into lp:openobject-client.

Requested reviews:
  OpenERP sa GTK client R&D (openerp-dev-gtk)
  Olivier Dony (OpenERP) (odo)

For more details, see:
https://code.launchpad.net/~openerp-commiter/openobject-client/passwd_change/+merge/45503

Hi, 

This merge allows the user to change his password from the menu User/Change 
password and even there is no relogin requirement anymore. 


Thanks
-- 
https://code.launchpad.net/~openerp-commiter/openobject-client/passwd_change/+merge/45503
Your team OpenERP sa GTK client R&D is requested to review the proposed merge 
of lp:~openerp-commiter/openobject-client/passwd_change into 
lp:openobject-client.
=== modified file 'bin/modules/gui/main.py'
--- bin/modules/gui/main.py	2010-12-16 09:18:15 +0000
+++ bin/modules/gui/main.py	2011-01-07 10:16:43 +0000
@@ -742,6 +742,7 @@
             'on_win_close_activate': self.sig_win_close,
             'on_support_activate': common.support,
             'on_preference_activate': self.sig_user_preferences,
+            'on_change_passwd_activate':lambda x:self.sig_db_password('user'),
             'on_read_requests_activate': self.sig_request_open,
             'on_send_request_activate': self.sig_request_new,
             'on_request_wait_activate': self.sig_request_wait,
@@ -765,7 +766,7 @@
             'on_db_restore_activate': self.sig_db_restore,
             'on_db_backup_activate': self.sig_db_dump,
             'on_db_drop_activate': self.sig_db_drop,
-            'on_admin_password_activate': self.sig_db_password,
+            'on_admin_password_activate': lambda x:self.sig_db_password('admin'),
             'on_extension_manager_activate': self.sig_extension_manager,
             'on_db_migrate_retrieve_script_activate': self.sig_db_migrate_retrieve_script,
             'on_db_migrate_activate' : self.sig_db_migrate,
@@ -917,10 +918,10 @@
         self.notebook.set_current_page(pn-1)
 
     def sig_user_preferences(self, *args):
-        win =win_preference.win_preference(parent=self.window)
+        win = win_preference.win_preference(parent=self.window)
         win.run()
         id = self.sb_company.get_context_id('message')
-        comp=self.company_set()
+        comp = self.company_set()
         if comp:
             self.sb_company.push(id, comp)
         else:
@@ -1415,7 +1416,7 @@
         win = win_extension.win_extension(self.window)
         win.run()
 
-    def sig_db_password(self, widget):
+    def sig_db_password(self, type):
         dialog = glade.XML(common.terp_path("openerp.glade"), "dia_passwd_change",
                 gettext.textdomain())
         win = dialog.get_widget('dia_passwd_change')
@@ -1423,40 +1424,66 @@
         win.set_transient_for(self.window)
         win.show_all()
         server_widget = dialog.get_widget('ent_server2')
+        ser_label = dialog.get_widget('label298')
         old_pass_widget = dialog.get_widget('old_passwd')
         new_pass_widget = dialog.get_widget('new_passwd')
         new_pass2_widget = dialog.get_widget('new_passwd2')
+        dia_label = dialog.get_widget('label294')
         change_button = dialog.get_widget('but_server_change1')
-        change_button.connect_after('clicked', lambda a,b: _server_ask(b, win), server_widget)
-
-        host = options.options['login.server']
-        port = options.options['login.port']
-        protocol = options.options['login.protocol']
-        url = '%s%s:%s' % (protocol, host, port)
-        server_widget.set_text(url)
-
-        res = win.run()
-        if res == gtk.RESPONSE_OK:
-            url = server_widget.get_text()
-            old_passwd = old_pass_widget.get_text()
-            new_passwd = new_pass_widget.get_text()
-            new_passwd2 = new_pass2_widget.get_text()
-            if new_passwd != new_passwd2:
-                common.warning(_("Confirmation password does not match " \
-                        "new password, operation cancelled!"),
-                        _("Validation Error."), parent=win)
+        old_pass_widget.grab_focus()
+
+        if type == 'admin':
+            host = options.options['login.server']
+            port = options.options['login.port']
+            protocol = options.options['login.protocol']
+            url = '%s%s:%s' % (protocol, host, port)
+            server_widget.set_text(url)
+            change_button.connect_after('clicked', lambda a,b: _server_ask(b, win), server_widget)
+        else:
+            dia_label.set_label(_('<b>Change your password</b>'))
+            server_widget.hide()
+            ser_label.hide()
+            change_button.hide()
+        end = False
+        while not end:
+            res = win.run()
+            if res == gtk.RESPONSE_OK:
+                old_passwd = old_pass_widget.get_text()
+                new_passwd = new_pass_widget.get_text()
+                new_passwd2 = new_pass2_widget.get_text()
+                if new_passwd != new_passwd2:
+                    new_pass_widget.set_text('')
+                    new_pass_widget.grab_focus()
+                    new_pass2_widget.set_text('')
+                    common.warning(_("Confirmation password does not match " \
+                            "new password, operation cancelled!"),
+                            _("Validation Error."), parent=win)
+                else:
+                    try:
+                        if type == 'user':
+                            rpc.session.rpc_exec_auth_wo('/object', 'execute', 'res.users', 'change_password',
+                                    old_passwd, new_passwd)
+                            rpc.session._passwd = new_passwd
+                        else:
+                            url = server_widget.get_text()
+                            rpc.session.db_exec(url, 'change_admin_password',
+                                    old_passwd, new_passwd)
+                        end = True
+                    except Exception, e:
+
+                        if type == 'admin':
+                            if ('faultCode' in dir(e) and e.faultCode=="AccessDenied") \
+                                    or 'AccessDenied' in str(e):
+                                    common.warning(_("Could not change the Super Admin password."),
+                                                   _('Bad password provided !'), parent=win)
+                        else:
+                            if e.type == 'warning':
+                                 common.warning(e.data, e.message, parent=win)
+                            elif e.type == 'AccessDenied':
+                                common.warning(_("Changing password failed, please verify old password."),
+                                               _('Bad password provided !'), parent=win)
             else:
-                try:
-                    rpc.session.db_exec(url, 'change_admin_password',
-                            old_passwd, new_passwd)
-                except Exception,e:
-                    if ('faultCode' in dir(e) and e.faultCode=="AccessDenied") \
-                            or str(e)=='AccessDenied':
-                        common.warning(_("Could not change the Super Admin password."),
-                                _('Bad password provided !'), parent=win)
-                    else:
-                        common.warning(_("Error, password not changed."),
-                                parent=win)
+                end = True
         self.window.present()
         win.destroy()
 

=== modified file 'bin/modules/gui/window/win_preference.py'
--- bin/modules/gui/window/win_preference.py	2011-01-05 09:01:44 +0000
+++ bin/modules/gui/window/win_preference.py	2011-01-07 10:16:43 +0000
@@ -80,9 +80,6 @@
         if res == gtk.RESPONSE_OK:
             values = self.screen.get()
             rpc.session.rpc_exec_auth('/object', 'execute', 'res.users', 'write', [rpc.session.uid], values)
-            passwd = values.get('password', False)
-            if passwd:
-                rpc.session._passwd = passwd
             rpc.session.context_reload()
             new_lang = rpc.session.context.get('lang', 'en_US')
             if lang != new_lang:

=== modified file 'bin/openerp.glade'
--- bin/openerp.glade	2010-12-21 19:39:25 +0000
+++ bin/openerp.glade	2011-01-07 10:16:43 +0000
@@ -478,6 +478,14 @@
                           </widget>
                         </child>
                         <child>
+                          <widget class="GtkImageMenuItem" id="change_passwd">
+                            <property name="visible">True</property>
+                            <property name="label" translatable="yes">Change password</property>
+                            <property name="use_underline">True</property>
+                            <signal name="activate" handler="on_change_passwd_activate"/>
+                          </widget>
+                        </child>
+                        <child>
                           <widget class="GtkSeparatorMenuItem" id="item2">
                             <property name="visible">True</property>
                           </widget>
@@ -7357,6 +7365,7 @@
                     <property name="can_focus">True</property>
                     <property name="max_length">16</property>
                     <property name="visibility">False</property>
+                    <property name="activates_default">True</property>
                   </widget>
                   <packing>
                     <property name="left_attach">1</property>
@@ -7372,6 +7381,7 @@
                     <property name="can_focus">True</property>
                     <property name="max_length">16</property>
                     <property name="visibility">False</property>
+                    <property name="activates_default">True</property>
                   </widget>
                   <packing>
                     <property name="left_attach">1</property>
@@ -7387,6 +7397,7 @@
                     <property name="can_focus">True</property>
                     <property name="max_length">16</property>
                     <property name="visibility">False</property>
+                    <property name="activates_default">True</property>
                   </widget>
                   <packing>
                     <property name="left_attach">1</property>

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to