[MERGE] [IMP] Misc view improvements using better name_get / name_search.
authorJitendra Prajapati <jpr@tinyerp.com>
Fri, 9 May 2014 09:49:20 +0000 (11:49 +0200)
committerThibault Delavallée <tde@openerp.com>
Fri, 9 May 2014 09:49:20 +0000 (11:49 +0200)
bzr revid: tde@openerp.com-20140509094920-94z2i7hfao3xxu4n

1  2 
openerp/addons/base/ir/ir_actions.py
openerp/addons/base/ir/ir_ui_view.py
openerp/addons/base/workflow/workflow.py

@@@ -1057,6 -1057,19 +1057,18 @@@ Launch Manually Once: after having bee
      }
      _order="sequence,id"
  
+     def name_get(self, cr, uid, ids, context=None):
+         return [(rec.id, rec.action_id.name) for rec in self.browse(cr, uid, ids, context=context)]
+     def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=100):
 -        if not args:
++        if args is None:
+             args = []
 -        ids = []
+         if name:
+             ids = self.search(cr, user, [('action_id', operator, name)] + args, limit=limit)
 -        else:
 -            super(ir_actions_todo, self).name_search(cr, user, name, args=args, operator=operator, context=context, limit=limit)
 -        return self.name_get(cr, user, ids, context=context)
++            return self.name_get(cr, user, ids, context=context)
++        return super(ir_actions_todo, self).name_search(cr, user, name, args=args, operator=operator, context=context, limit=limit)
++
      def action_launch(self, cr, uid, ids, context=None):
          """ Launch Action of Wizard"""
          wizard_id = ids and ids[0] or False
@@@ -68,6 -68,19 +68,18 @@@ class view_custom(osv.osv)
          'arch': fields.text('View Architecture', required=True),
      }
  
+     def name_get(self, cr, uid, ids, context=None):
+         return [(rec.id, rec.user_id.name) for rec in self.browse(cr, uid, ids, context=context)]
+     def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=100):
 -        if not args:
++        if args is None:
+             args = []
 -        ids = []
+         if name:
+             ids = self.search(cr, user, [('user_id', operator, name)] + args, limit=limit)
 -        else:
 -            super(view_custom, self).name_search(cr, user, name, args=args, operator=operator, context=context, limit=limit)
 -        return self.name_get(cr, user, ids, context=context)
++            return self.name_get(cr, user, ids, context=context)
++        return super(view_custom, self).name_search(cr, user, name, args=args, operator=operator, context=context, limit=limit)
++
      def _auto_init(self, cr, context=None):
          super(view_custom, self)._auto_init(cr, context)
          cr.execute('SELECT indexname FROM pg_indexes WHERE indexname = \'ir_ui_view_custom_user_id_ref_id\'')
@@@ -123,6 -123,20 +123,19 @@@ class wkf_transition(osv.osv)
      _defaults = {
          'condition': lambda *a: 'True',
      }
+     def name_get(self, cr, uid, ids, context=None):
+         return [(line.id, (line.act_from.name) + '+' + (line.act_to.name)) if line.signal == False else (line.id, line.signal) for line in self.browse(cr, uid, ids, context=context)]
+     def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=100):
 -        if not args:
++        if args is None:
+             args = []
 -        ids = []
+         if name:
+             ids = self.search(cr, user, ['|',('act_from', operator, name),('act_to', operator, name)] + args, limit=limit)
 -        else:
 -            super(wkf_transition, self).name_search(cr, user, name, args=args, operator=operator, context=context, limit=limit)
 -        return self.name_get(cr, user, ids, context=context)
++            return self.name_get(cr, user, ids, context=context)
++        return super(wkf_transition, self).name_search(cr, user, name, args=args, operator=operator, context=context, limit=limit)
++
  wkf_transition()
  
  class wkf_instance(osv.osv):