Skip to content
Extraits de code Groupes Projets
Valider 702c5c22 rédigé par Rémi - Le Filament's avatar Rémi - Le Filament
Parcourir les fichiers

[ADD] alarm handling Bluemind --> Odoo

parent bea4fb45
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -35,6 +35,8 @@ from netbluemind.icalendar.api.ICalendarElementRRuleWeekDay import (
ICalendarElementRRuleWeekDay,
)
from netbluemind.icalendar.api.ICalendarElementStatus import ICalendarElementStatus
from netbluemind.icalendar.api.ICalendarElementVAlarm import ICalendarElementVAlarm
from netbluemind.icalendar.api.ICalendarElementVAlarmAction import ICalendarElementVAlarmAction
from netbluemind.python.client import ServerFault
from pytz import timezone
......@@ -69,7 +71,7 @@ PARTSTATUS_CONVERTER_O2B = {
}
# TODO: manage alarm_ids, categories, attachments ?
# TODO: manage categories, attachments ?
# TODO: check if recurrency properly working without exceptions
# TODO: manage exceptions in recurrencies
class CalendarEvent(models.Model):
......@@ -158,7 +160,8 @@ class CalendarEvent(models.Model):
}
)
# TODO: Add attendees handling
# TODO: Add attendees handling - how to manage already existing ids ?
# TODO: Add alarms handling - how to manage already existing ids ?
# Returns data dictionary
return data
......@@ -200,6 +203,7 @@ class CalendarEvent(models.Model):
# These fields are required (although not marked as such in doc / code)
# Otherwise you get a NullPointerException
# Manage attendees
bm_event.main.attendees = []
for attendee in self.attendee_ids:
att = ICalendarElementAttendee()
......@@ -232,6 +236,16 @@ class CalendarEvent(models.Model):
att.internal = False
att.mailto = attendee.partner_id.email or ""
bm_event.main.attendees.append(att)
# Manage alarms
bm_event.main.alarm = []
for alarm in self.alarm_ids:
al = ICalendarElementVAlarm()
if alarm.alarm_type = "notification":
al.action = ICalendarElementVAlarmAction("Display")
else:
al.action = ICalendarElementVAlarmAction("Email")
al.trigger = alarm.duration_minutes * -60
bm_event.main.alarm.append(al)
# The following fields are not computed (yet ?)
bm_event.main.categories = []
bm_event.main.attachments = []
......@@ -359,7 +373,7 @@ class CalendarEvent(models.Model):
# AFAICT Bluemind needs all the fields to be provided,
# you cannot send only the updated ones
if result and not from_bluemind:
if result and not from_bluemind and self.user_id.is_bm_connection_ok:
# Create a list of Bluemind events to be updated
bm_events = VEventChanges()
bm_events.modify = []
......@@ -400,6 +414,7 @@ class CalendarEvent(models.Model):
"""
# Calls base create() function first
odoo_events = super().create(vals_list)
if self.user_id.is_bm_connection_ok:
self.create_odoo_events_in_bm()
return odoo_events
......@@ -410,7 +425,7 @@ class CalendarEvent(models.Model):
A parameter is added "from_bluemind" to avoid deleting a Bluemind event
when deletion is already coming from Bluemind
"""
if not from_bluemind:
if not from_bluemind and self.user_id.is_bm_connection_ok:
for event in self:
# If Odoo event is linked to a Bluemind event
if event.bluemind_id:
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter