From 2bb37b5d1e41d9dd21ec59b8913b7ec366f0bc29 Mon Sep 17 00:00:00 2001 From: Richard Mathot Date: Tue, 27 Sep 2016 18:50:49 +0200 Subject: [PATCH] [FIX] calendar: don't crash on missing optional dependency For historical reasons, `vobject`* Python library is not mandatory in Odoo. Since refactoring 6af6148a243374b7004aae719b9855df9393913e, get_ics_file() returns now a dictionary whose keys are calendar.event ids and values are the corresponding ics file. If `vobject` is not available, it returns an empty dictionary that could cause calendar.py to crash because it always expects to find the event's key. Before this refactoring, this method was called and architectured in a different manner, so no crash was happening. This commit prevents the crash if `vobject` is not installed and logs a warning. *vobject allows to generate iCalendar files --- addons/calendar/models/calendar.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/calendar/models/calendar.py b/addons/calendar/models/calendar.py index 315f2f5d411..bd65166fd65 100644 --- a/addons/calendar/models/calendar.py +++ b/addons/calendar/models/calendar.py @@ -160,7 +160,7 @@ class Attendee(models.Model): mails_to_send = self.env['mail.mail'] for attendee in self: if attendee.email or attendee.partner_id.email: - ics_file = ics_files[attendee.event_id.id] + ics_file = ics_files.get(attendee.event_id.id) mail_id = invitation_template.send_mail(attendee.id) vals = {} @@ -850,6 +850,7 @@ class Meeting(models.Model): # FIXME: why isn't this in CalDAV? 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: