From e67372146d38cdc77f7cf4ede1ccb0e76f136489 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Fri, 13 Mar 2015 12:13:36 +0100 Subject: [PATCH] [FIX] hr_holidays: correct leave type order. Leaves types must be ordered depending on the remaining leaves for the current user. --- addons/hr_holidays/hr_holidays.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/addons/hr_holidays/hr_holidays.py b/addons/hr_holidays/hr_holidays.py index 4d3a0bc8182..6bc84b1cce2 100644 --- a/addons/hr_holidays/hr_holidays.py +++ b/addons/hr_holidays/hr_holidays.py @@ -125,11 +125,8 @@ class hr_holidays_status(osv.osv): ids = super(hr_holidays_status, self)._search(cr, uid, args, offset=offset, limit=limit, order=order, context=context, count=count, access_rights_uid=access_rights_uid) if not count and not order and context.get('employee_id'): leaves = self.browse(cr, uid, ids, context=context) - # perform a 2-steps sort because sorting on reminaing leaves is reversed - # sorted keep the order and is stable so 2-steps - sorted_leaves = leaves.sorted(key=attrgetter('limit')) - sorted_leaves = leaves.sorted(key=attrgetter('virtual_remaining_leaves'), reverse=True) - return [leave.id for leave in sorted_leaves] + sort_key = lambda l: (not l.limit, l.virtual_remaining_leaves) + return map(int, leaves.sorted(key=sort_key, reverse=True)) return ids