← Back to team overview

openerp-dev-web team mailing list archive

[Merge] lp:~openerp-dev/openobject-server/trunk-bug-751677-ysa into lp:openobject-server

 

Naresh(OpenERP) has proposed merging lp:~openerp-dev/openobject-server/trunk-bug-751677-ysa into lp:openobject-server.

Requested reviews:
  Naresh(OpenERP) (nch-openerp)
Related bugs:
  Bug #751677 in OpenERP Server: "Unable to add users with wizard"
  https://bugs.launchpad.net/openobject-server/+bug/751677

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-server/trunk-bug-751677-ysa/+merge/61716

problem fix in add user using configuration wizard.
-- 
https://code.launchpad.net/~openerp-dev/openobject-server/trunk-bug-751677-ysa/+merge/61716
Your team OpenERP R&D Team is subscribed to branch lp:~openerp-dev/openobject-server/trunk-bug-751677-ysa.
=== modified file 'openerp/addons/base/__openerp__.py'
--- openerp/addons/base/__openerp__.py	2011-03-02 08:35:38 +0000
+++ openerp/addons/base/__openerp__.py	2011-05-20 08:51:47 +0000
@@ -94,6 +94,7 @@
         'test/bug_lp541545.xml',
         'test/test_osv_expression.yml',
         'test/test_ir_rule.yml', # <-- These tests modify/add/delete ir_rules.
+        'test/test_config_users.yml'
     ],
     'installable': True,
     'active': True,

=== modified file 'openerp/addons/base/res/res_user.py'
--- openerp/addons/base/res/res_user.py	2011-05-06 09:37:04 +0000
+++ openerp/addons/base/res/res_user.py	2011-05-20 08:51:47 +0000
@@ -206,6 +206,9 @@
             raise osv.except_osv(_('Operation Canceled'), _('Please use the change password wizard (in User Preferences or User menu) to change your own password.'))
         self.write(cr, uid, id, {'password': value})
 
+    def _get_password(self, cr, uid, ids, arg, karg, context=None):
+        return dict.fromkeys(ids, '')
+
     _columns = {
         'name': fields.char('User Name', size=64, required=True, select=True,
                             help="The new user's real name, used for searching"
@@ -213,7 +216,7 @@
         'login': fields.char('Login', size=64, required=True,
                              help="Used to log into the system"),
         'password': fields.char('Password', size=64, invisible=True, help="Keep empty if you don't want the user to be able to connect on the system."),
-        'new_password': fields.function(lambda *a:'', method=True, type='char', size=64,
+        'new_password': fields.function(_get_password, method=True, type='char', size=64,
                                 fnct_inv=_set_new_password,
                                 string='Change password', help="Only specify a value if you want to change the user password. "
                                 "This user will have to logout and login again!"),
@@ -263,7 +266,6 @@
             if 'password' in o and ( 'id' not in o or o['id'] != uid ):
                 o['password'] = '********'
             return o
-
         result = super(users, self).read(cr, uid, ids, fields, context, load)
         canwrite = self.pool.get('ir.model.access').check(cr, uid, 'res.users', 'write', raise_exception=False)
         if not canwrite:
@@ -535,15 +537,17 @@
                       'email': base_data['email'],
                       'partner_id': partner_id,},
             context)
-        user_data = dict(
-            base_data,
-            signature=self._generate_signature(
-                cr, base_data['name'], base_data['email'], context=context),
-            address_id=address,
-            )
+        base_data.update({'menu_id' : base_data.get('menu_id',False) and base_data['menu_id'][0],
+                          'company_id' : base_data.get('company_id',False) and base_data['company_id'][0],
+                          'action_id' :  base_data.get('action_id',False) and base_data['action_id'][0],
+                          'signature' : self._generate_signature(cr, base_data['name'], base_data['email'], context=context),
+                          'address_id' : address,
+                          'groups_id' : [(6,0, base_data.get('groups_id',[]))],
+                })
         new_user = self.pool.get('res.users').create(
-            cr, uid, user_data, context)
+            cr, uid, base_data, context)
         self.send_welcome_email(cr, uid, new_user, context=context)
+
     def execute(self, cr, uid, ids, context=None):
         'Do nothing on execution, just launch the next action/todo'
         pass

=== added file 'openerp/addons/base/test/test_config_users.yml'
--- openerp/addons/base/test/test_config_users.yml	1970-01-01 00:00:00 +0000
+++ openerp/addons/base/test/test_config_users.yml	2011-05-20 08:51:47 +0000
@@ -0,0 +1,14 @@
+-
+  I Create "test" user using configuration wizard.
+-
+  !python {model: res.config.users}: |
+    default_value = self.default_get(cr, uid, ['name','login','password','active','context_lang','active','menu_id','company_id','address_id','menu_tips'])
+    print "default_value::",default_value
+    default_value.update({
+              'name' : 'test1',
+              'login' : 'test1',
+              'password' : 'test',
+              'email' : 'test@xxxxxxxxxxx',
+          })
+    wizard_id = self.create(cr, uid, default_value)
+    self.action_add(cr, uid, [wizard_id], context)


Follow ups