[IMP] res_users: implement sorting on full_name

bzr revid: rco@openerp.com-20111209080319-otm4tr2ezw60109l
This commit is contained in:
Raphael Collet 2011-12-09 09:03:19 +01:00
parent 0940bea6f1
commit cda72d1e96
1 changed files with 10 additions and 0 deletions

View File

@ -65,6 +65,16 @@ class groups(osv.osv):
('name_uniq', 'unique (COALESCE(category_id, 0), name)', 'The name of the group must be unique !')
]
def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False):
# add explicit ordering if search is sorted on full_name
if order and order.startswith('full_name'):
ids = super(groups, self).search(cr, uid, args, context=context)
gs = self.browse(cr, uid, ids, context)
gs.sort(key=lambda g: g.full_name, reverse=order.endswith('DESC'))
gs = gs[offset:offset+limit] if limit else gs[offset:]
return map(int, gs)
return super(groups, self).search(cr, uid, args, offset, limit, order, context, count)
def copy(self, cr, uid, id, default=None, context=None):
group_name = self.read(cr, uid, [id], ['name'])[0]['name']
default.update({'name': _('%s (copy)')%group_name})