'Override _search to order the results, according to some employee.
The order is the following
- limit (limited leaves first, such as Legal Leaves)
- virtual remaining leaves (higher the better, so using reverse on sorted)
This override is necessary because those fields are not stored and depends
on an employee_id given in context. This sort will be done when there
is an employee_id in context and that no other order has been given
to the method.'

@api.model
def _search(self, args, offset=0, limit=None, order=None, count=False, access_rights_uid=None):

    leave_ids = super(HolidaysType, self)._search(args, offset=offset, limit=limit, order=order, count=count, access_rights_uid=access_rights_uid)
    if ((not count) and (not order) and self._context.get('employee_id')):
        leaves = self.browse(leave_ids)
        sort_key = (lambda l: ((not l.limit), l.virtual_remaining_leaves))
        return map(int, leaves.sorted(key=sort_key, reverse=True))
    return leave_ids
