caldav_sync: add video conference and alarms sync

This commit is contained in:
Marc Durepos 2024-05-28 10:13:43 -04:00
parent 4781b33123
commit 10eb3ae569
2 changed files with 17 additions and 2 deletions

View file

@ -8,7 +8,7 @@
{
'name': 'CalDAV Synchronization',
'version': '17.0.0.5.2',
'version': '17.0.0.5.3',
'license': 'LGPL-3',
'category': 'Productivity',
'summary': 'Synchronize Odoo Calendar Events with CalDAV Servers',

View file

@ -152,7 +152,21 @@ class CalendarEvent(models.Model):
ical_event.add('description', event.description)
if event.location:
ical_event.add('location', event.location)
if event.videocall_location:
ical_event.add('CONFERENCE', event.videocall_location)
for partner in event.partner_ids:
attendee = vCalAddress(f'MAILTO:{partner.email}')
attendee.params['cn'] = vText(partner.name)
attendee_record = self.env['calendar.attendee'].search([('event_id', '=', event.id), ('partner_id', '=', partner.id)], limit=1)
if attendee_record:
attendee.params['partstat'] = vText(self._map_attendee_status(attendee_record.state))
ical_event.add('attendee', attendee, encode=0)
for alarm in event.alarm_ids:
ical_alarm = Alarm()
ical_alarm.add('trigger', alarm.trigger)
ical_alarm.add('action', 'DISPLAY')
ical_alarm.add('description', alarm.name or 'Reminder')
ical_event.add_component(ical_alarm)
# Add RRULE if the event is recurrent
if event.recurrency and event.recurrence_id:
rrule = event.recurrence_id._get_rrule()
@ -310,6 +324,7 @@ class CalendarEvent(models.Model):
'stop': end,
'description': str(component.get('description')),
'location': str(component.get('location')),
'videocall_location': str(component.get('conference')),
'caldav_uid': uid,
'partner_ids': [(6, 0, attendee_ids.ids)],
}