[ADD][WIP]Radicale Odoo Storage : add alarms management from Odoo
This commit is contained in:
parent
800cc260ed
commit
81e84e7b28
@ -29,6 +29,7 @@
|
||||
|
||||
from contextlib import contextmanager
|
||||
from time import strftime, strptime
|
||||
from datetime import timedelta
|
||||
import pytz
|
||||
import vobject
|
||||
from odoorpc import ODOO
|
||||
@ -193,6 +194,7 @@ class Collection(BaseCollection):
|
||||
@classmethod
|
||||
def _generate_ics_from_odoo(cls, href, event):
|
||||
""" Generate and return UCS object from Odoo calendar.event record """
|
||||
# TODO/IMP : attendees management (not handled directly by vobject)
|
||||
utc_dtstart = cls.odoo_date_to_utc(event.start_datetime)
|
||||
utc_dtstop = cls.odoo_date_to_utc(event.stop_datetime)
|
||||
last_modified = str(cls.odoo_date_to_utc(event.write_date))
|
||||
@ -207,6 +209,12 @@ class Collection(BaseCollection):
|
||||
if event.categ_ids:
|
||||
categs = [categ.name for categ in event.categ_ids]
|
||||
cal.vevent.add('categories').value = categs
|
||||
if event.alarm_ids:
|
||||
for alarm in event.alarm_ids:
|
||||
valarm = cal.vevent.add('valarm')
|
||||
action = 'DISPLAY' if alarm.type == 'notification' else 'EMAIL'
|
||||
valarm.add('action').value = action
|
||||
valarm.add('trigger').value = timedelta(minutes=-alarm.duration_minutes)
|
||||
cal.vevent.add('uid').value = href
|
||||
cal.vevent.add('rev').value = last_modified
|
||||
cal.add('rev').value = last_modified
|
||||
|
Loading…
Reference in New Issue
Block a user