From 671962ca5c1dfb286f8af4c9b59115185cdec082 Mon Sep 17 00:00:00 2001 From: Fabien BOURGEOIS Date: Fri, 11 May 2018 16:15:56 +0200 Subject: [PATCH] [ADD][WIP]Radicale Odoo Storage : event recurrency handling --- radicale_odoo_storage/__init__.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/radicale_odoo_storage/__init__.py b/radicale_odoo_storage/__init__.py index 346a364..78cca82 100644 --- a/radicale_odoo_storage/__init__.py +++ b/radicale_odoo_storage/__init__.py @@ -21,10 +21,11 @@ # 1. OK : Implement readonly from Odoo only # 2. OK : Implement contacts first (and so vcf) # 3. OK : Implement unique events (.ics) and timezone -# 4. Implement notifications for events -# 5. Implement recurrent events -# 6. Begin write (two way) for contacts -# 7. Begin write (two way) for calendar +# 4. OK : Implement notifications for events +# 5. OK : Implement recurrent events +# 6. Offer two (or more) calendar : own events, events where I'm attended and all readable events +# 7. Begin write (two way) for contacts +# 8. Begin write (two way) for calendar from contextlib import contextmanager @@ -130,7 +131,10 @@ class Collection(BaseCollection): def get_events_from_odoo(cls, login): """ Gets all events available from one Odoo login """ cls.logger.info('Get events for Odoo user %s' % login) + cls.odoo.env.context.update({'virtual_id': False}) # Only real events event_ids = cls.odoo.env['calendar.event'].search([]) + # WARNING: Odoo does not remove from database deleted recurrent events... + # Should be fixed on Odoo side and will be fixed via 2way here too return ['calendar.event:%s' % eid for eid in event_ids] def sync(self, old_token=None): @@ -219,6 +223,8 @@ class Collection(BaseCollection): action = 'DISPLAY' if alarm.type == 'notification' else 'EMAIL' valarm.add('action').value = action valarm.add('trigger').value = timedelta(minutes=-alarm.duration_minutes) + if event.recurrency: + cal.vevent.add('rrule').value = event.rrule cal.vevent.add('uid').value = href cal.vevent.add('rev').value = last_modified cal.add('rev').value = last_modified