[MERGE] Forward-port of latest saas-2 bugfixes, up to rev.5012 revid:mat@openerp...
authorMartin Trigaux <mat@openerp.com>
Wed, 19 Feb 2014 14:06:17 +0000 (15:06 +0100)
committerMartin Trigaux <mat@openerp.com>
Wed, 19 Feb 2014 14:06:17 +0000 (15:06 +0100)
bzr revid: mat@openerp.com-20140219140617-na0q47yaloblb67i

1  2 
openerp/addons/base/ir/ir_actions.py
openerp/addons/base/res/res_users.py
openerp/osv/fields.py
openerp/osv/orm.py
openerp/service/db.py

@@@ -910,11 -973,38 +912,38 @@@ class ir_actions_server(osv.osv)
          if action.link_new_record and action.link_field_id:
              self.pool[action.model_id.model].write(cr, uid, [context.get('active_id')], {action.link_field_id.name: res_id})
  
+     def _eval_context_for_action(self, cr, uid, action, context=None):
+         if context is None:
+             context = {}
+         model = self.pool[action.model_id.model]
+         active_id = context.get('active_id')
+         active_ids = context.get('active_ids', [active_id] if active_id else [])
+         target_record = None
+         if context.get('active_model') == action.model_id.model and active_id:
+             context = dict(context, active_ids=active_ids, active_id=active_id)
+             target_record = model.browse(cr, uid, active_id, context=context) if active_id else None
+         user = self.pool['res.users'].browse(cr, uid, uid)
+         eval_context = {
+             'self': model,
+             'object': target_record,
+             'obj': target_record,
+             'pool': self.pool,
+             'time': time,
+             'datetime': datetime,
+             'dateutil': dateutil,
+             'cr': cr,
+             'uid': uid,
+             'user': user,
+             'context': context,
+         }
+         return eval_context
      def run(self, cr, uid, ids, context=None):
 -        """ Run the server action. For each server action, the condition is
 -        checked. Note that A void (aka False) condition is considered as always
 +        """ Runs the server action. For each server action, the condition is
 +        checked. Note that a void (``False``) condition is considered as always
          valid. If it is verified, the run_action_<STATE> method is called. This
 -        allows easy inheritance of the server actions.
 +        allows easy overriding of the server actions.
  
          :param dict context: context should contain following keys
  
@@@ -869,67 -876,4 +869,69 @@@ class users_view(osv.osv)
                      }
          return res
  
 +#----------------------------------------------------------
 +# change password wizard
 +#----------------------------------------------------------
 +
 +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)
++        # don't keep temporary password copies in the database longer than necessary
++        self.pool.get('change.password.user').unlink(cr, uid, user_ids)
 +        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})
 +
 +
  # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
Simple merge
Simple merge
@@@ -311,9 -333,11 +311,9 @@@ def exp_list(document=False)
                  cr.execute("select datname from pg_database where datdba=(select usesysid from pg_user where usename=%s) and datname not in %s order by datname", (db_user, templates_list))
              else:
                  cr.execute("select datname from pg_database where datname not in %s order by datname", (templates_list,))
-             res = [str(name) for (name,) in cr.fetchall()]
+             res = [tools.ustr(name) for (name,) in cr.fetchall()]
          except Exception:
              res = []
 -    finally:
 -        cr.close()
      res.sort()
      return res