'Get the leaves of the calendar. Leaves can be filtered on the resource,
the start datetime or the end datetime.
:param int resource_id: the id of the resource to take into account when
computing the leaves. If not set, only general
leaves are computed. If set, generic and
specific leaves are computed.
:param datetime start_datetime: if provided, do not take into account leaves
ending before this date.
:param datetime end_datetime: if provided, do not take into account leaves
beginning after this date.
:return list leaves: list of tuples (start_datetime, end_datetime) of
leave intervals'

@api.multi
def get_leave_intervals(self, resource_id=None, start_datetime=None, end_datetime=None):

    self.ensure_one()
    leaves = []
    for leave in self.leave_ids:
        if (leave.resource_id and (not (resource_id == leave.resource_id.id))):
            continue
        date_from = fields.Datetime.from_string(leave.date_from)
        if (end_datetime and (date_from > end_datetime)):
            continue
        date_to = fields.Datetime.from_string(leave.date_to)
        if (start_datetime and (date_to < start_datetime)):
            continue
        leaves.append((date_from, date_to, leave.group_id.id))
    return leaves
