'Returns iCalendar file for the event invitation.
:returns a dict of .ics file content for each meeting'

@api.multi
def get_ics_file(self):

    result = {}
    def ics_datetime(idate, allday=False):
        if idate:
            if allday:
                return fields.Date.from_string(idate)
            else:
                return fields.Datetime.from_string(idate).replace(tzinfo=pytz.timezone('UTC'))
        return False
    try:
        import vobject
    except ImportError:
        _logger.warning("The    `vobject`    Python    module    is    not    installed,    so    iCal    file    generation    is    unavailable.    Use    'pip    install    vobject'    to    install    it")
        return result
    for meeting in self:
        cal = vobject.iCalendar()
        event = cal.add('vevent')
        if ((not meeting.start) or (not meeting.stop)):
            raise UserError(_('First    you    have    to    specify    the    date    of    the    invitation.'))
        event.add('created').value = ics_datetime(time.strftime(DEFAULT_SERVER_DATETIME_FORMAT))
        event.add('dtstart').value = ics_datetime(meeting.start, meeting.allday)
        event.add('dtend').value = ics_datetime(meeting.stop, meeting.allday)
        event.add('summary').value = meeting.name
        if meeting.description:
            event.add('description').value = meeting.description
        if meeting.location:
            event.add('location').value = meeting.location
        if meeting.rrule:
            event.add('rrule').value = meeting.rrule
        if meeting.alarm_ids:
            for alarm in meeting.alarm_ids:
                valarm = event.add('valarm')
                interval = alarm.interval
                duration = alarm.duration
                trigger = valarm.add('TRIGGER')
                trigger.params['related'] = ['START']
                if (interval == 'days'):
                    delta = timedelta(days=duration)
                elif (interval == 'hours'):
                    delta = timedelta(hours=duration)
                elif (interval == 'minutes'):
                    delta = timedelta(minutes=duration)
                trigger.value = delta
                valarm.add('DESCRIPTION').value = (alarm.name or 'Odoo')
        for attendee in meeting.attendee_ids:
            attendee_add = event.add('attendee')
            attendee_add.value = ('MAILTO:' + (attendee.email or ''))
        result[meeting.id] = cal.serialize()
    return result
