[IMP]: Caldav : * Removed unused functions in caldav
* Implement code for export data in caldav instead of crm module * Restructured Alarm and given proper names * Improved code bzr revid: rpa@tinyerp.com-20091216141620-crrxthuk0yqkj3fp
This commit is contained in:
+139
-194
@@ -20,17 +20,16 @@
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from osv import fields, osv
|
||||
from time import strftime
|
||||
import time
|
||||
import base64
|
||||
import vobject
|
||||
from dateutil.rrule import *
|
||||
from dateutil import parser
|
||||
from datetime import datetime
|
||||
from time import strftime
|
||||
from dateutil import parser
|
||||
from dateutil.rrule import *
|
||||
from osv import fields, osv
|
||||
from pytz import timezone
|
||||
from time import strftime
|
||||
import base64
|
||||
import re
|
||||
import time
|
||||
import vobject
|
||||
|
||||
# O-1 Optional and can come only once
|
||||
# O-n Optional and can come more than once
|
||||
@@ -68,12 +67,9 @@ def map_data(cr, uid, obj):
|
||||
return vals
|
||||
|
||||
class CalDAV(object):
|
||||
__attribute__= {
|
||||
__attribute__ = {
|
||||
}
|
||||
|
||||
def ical_items(self):
|
||||
return self.__attribute__.items()
|
||||
|
||||
def ical_set(self, name, value, type):
|
||||
if name in self.__attribute__ and self.__attribute__[name]:
|
||||
self.__attribute__[name][type] = value
|
||||
@@ -92,8 +88,45 @@ class CalDAV(object):
|
||||
else:
|
||||
return self.__attribute__.get(name, None)
|
||||
|
||||
def export_ical(self):
|
||||
pass
|
||||
def export_ical(self, cr, uid, datas):
|
||||
ical = vobject.iCalendar()
|
||||
for data in datas:
|
||||
vevent = ical.add('vevent')
|
||||
for field in self.__attribute__.keys():
|
||||
map_field = self.ical_get(field, 'field')
|
||||
map_type = self.ical_get(field, 'type')
|
||||
if map_field in data.keys():
|
||||
if field == 'attendee':
|
||||
attendee_object = self.pool.get('crm.caldav.attendee')
|
||||
for attendee in attendee_object.read(cr, uid, data[map_field], []):
|
||||
attendee_add = vevent.add('attendee')
|
||||
for a_key, a_val in attendee_object.__attribute__.items():
|
||||
if attendee[a_val['field']]:
|
||||
if a_val['type'] == 'text':
|
||||
attendee_add.params[a_key] = [str(attendee[a_val['field']])]
|
||||
elif a_val['type'] == 'boolean':
|
||||
attendee_add.params[a_key] = [str(attendee[a_val['field']])]
|
||||
elif field == 'valarm':
|
||||
alarm = vevent.add('valarm')
|
||||
alarm_object = self.pool.get('crm.caldav.alarm')
|
||||
alarm_data = alarm_object.read(cr, uid, data[map_field][0], [])
|
||||
interval = alarm_data['trigger_interval']
|
||||
duration = alarm_data['trigger_duration']
|
||||
related = alarm_data['trigger_related']
|
||||
occurs = alarm_data['trigger_occurs']
|
||||
value_string = (occurs == 'BEFORE' and '-P' or 'P') +\
|
||||
str(duration) + interval[0]
|
||||
elif data[map_field]:
|
||||
if map_type == "text":
|
||||
vevent.add(field).value = str(data[map_field])
|
||||
elif map_type == 'datetime' and data[map_field]:
|
||||
vevent.add(field).value = datetime.strptime(data[map_field], \
|
||||
"%Y-%m-%d %H:%M:%S")
|
||||
if self.__attribute__.get(field).has_key('mapping'):
|
||||
for key1, val1 in self.ical_get(field, 'mapping').items():
|
||||
if val1 == data[map_field]:
|
||||
vevent.add(field).value = key1
|
||||
return ical
|
||||
|
||||
def import_ical(self, cr, uid, ical_data):
|
||||
parsedCal = vobject.readOne(ical_data)
|
||||
@@ -103,12 +136,12 @@ class CalDAV(object):
|
||||
if cal_data.name.lower() == 'attendee':
|
||||
attendee = self.pool.get('caldav.attendee')
|
||||
att_data.append(attendee.import_ical(cr, uid, cal_data))
|
||||
self.ical_set(cal_data.name.lower(), att_data , 'value')
|
||||
self.ical_set(cal_data.name.lower(), att_data, 'value')
|
||||
continue
|
||||
if cal_data.name.lower() == 'valarm':
|
||||
alarm = self.pool.get('caldav.alarm')
|
||||
vals = alarm.import_ical(cr, uid, cal_data)
|
||||
self.ical_set(cal_data.name.lower(), vals , 'value')
|
||||
self.ical_set(cal_data.name.lower(), vals, 'value')
|
||||
continue
|
||||
if cal_data.name.lower() in self.__attribute__:
|
||||
self.ical_set(cal_data.name.lower(), cal_data.value, 'value')
|
||||
@@ -119,127 +152,58 @@ class CalDAV(object):
|
||||
class Calendar(CalDAV, osv.osv_memory):
|
||||
_name = 'caldav.calendar'
|
||||
__attribute__ = {
|
||||
'prodid' : None, # Use: R-1, Type: TEXT, Specifies the identifier for the product that created the iCalendar object.
|
||||
'version' : None, # Use: R-1, Type: TEXT, Specifies the identifier corresponding to the highest version number
|
||||
'prodid': None, # Use: R-1, Type: TEXT, Specifies the identifier for the product that created the iCalendar object.
|
||||
'version': None, # Use: R-1, Type: TEXT, Specifies the identifier corresponding to the highest version number
|
||||
# or the minimum and maximum range of the iCalendar specification
|
||||
# that is required in order to interpret the iCalendar object.
|
||||
'calscale' : None, # Use: O-1, Type: TEXT, Defines the calendar scale used for the calendar information specified in the iCalendar object.
|
||||
'method' : None, # Use: O-1, Type: TEXT, Defines the iCalendar object method associated with the calendar object.
|
||||
'vevent' : None, # Use: O-n, Type: Collection of Event class
|
||||
'vtodo' : None, # Use: O-n, Type: Collection of ToDo class
|
||||
'calscale': None, # Use: O-1, Type: TEXT, Defines the calendar scale used for the calendar information specified in the iCalendar object.
|
||||
'method': None, # Use: O-1, Type: TEXT, Defines the iCalendar object method associated with the calendar object.
|
||||
'vevent': None, # Use: O-n, Type: Collection of Event class
|
||||
'vtodo': None, # Use: O-n, Type: Collection of ToDo class
|
||||
'vjournal': None, # Use: O-n, Type: Collection of Journal class
|
||||
'vfreebusy': None, # Use: O-n, Type: Collection of FreeBusy class
|
||||
'vtimezone': None, # Use: O-n, Type: Collection of Timezone class
|
||||
|
||||
}
|
||||
|
||||
def import_ical(self, cr, uid, ical_data):
|
||||
# Write openobject data from ical_data
|
||||
|
||||
ical = vobject.readOne(ical_data)
|
||||
for child in ical.getChildren():
|
||||
child_name = child.name.lower()
|
||||
if child_name == 'vevent':
|
||||
for event in child.getChildren():
|
||||
if event.name.lower() =="attendee":
|
||||
attendee = Attendee()
|
||||
attendee.import_ical(cr, uid, event)
|
||||
if event.name.lower() =="valarm":
|
||||
alarm = Alarm()
|
||||
alarm.import_ical(cr, uid, event)
|
||||
elif child_name == "vtimezone":
|
||||
timezone = Timezone()
|
||||
timezone.import_ical(cr, uid, child)
|
||||
return True
|
||||
|
||||
def export_ical(self, cr, uid, ids):
|
||||
# Read openobject data in ical format
|
||||
ical = vobject.iCalendar()
|
||||
datas = self.browse(cr, uid, ids)
|
||||
|
||||
vcal = ical.add('vcalendar')
|
||||
for name, value in self.ical_items():
|
||||
if not value:
|
||||
continue
|
||||
if name == 'vevent':
|
||||
for event in value:
|
||||
vevent = event.ical_read()
|
||||
vcal.add(vevent)
|
||||
elif name == 'vtodo':
|
||||
for todo in value:
|
||||
vtodo = todo.ical_read()
|
||||
vcal.add(vtodo)
|
||||
elif name == 'vjournal':
|
||||
for journal in value:
|
||||
vjournal = journal.ical_read()
|
||||
vcal.add(vjournal)
|
||||
elif name == 'vfreebusy':
|
||||
for freebusy in value:
|
||||
vfreebusy = freebusy.ical_read()
|
||||
vcal.add(vfreebusy)
|
||||
elif name == 'vtimezone':
|
||||
for timezone in value:
|
||||
vtimezone = timezone.ical_read()
|
||||
vcal.add(vtimezone)
|
||||
else:
|
||||
vcal.add(name).value = value
|
||||
s = ical.serialize()
|
||||
return s
|
||||
|
||||
def ical_write(self, data):
|
||||
ical = vobject.readOne(data)
|
||||
for child in ical.getChildren():
|
||||
child_name = child.name.lower()
|
||||
child_value = child.value
|
||||
if child_name == 'vevent':
|
||||
vevents = []
|
||||
for event in child.getChildren():
|
||||
vevent = Event()
|
||||
vevent.ical_write(event.serialize())
|
||||
vevents.append(vevent)
|
||||
self.ical_set(child_name, vevents)
|
||||
else:
|
||||
self.ical_set(child_name, child_value)
|
||||
return True
|
||||
|
||||
Calendar()
|
||||
|
||||
class Event(CalDAV, osv.osv_memory):
|
||||
_name = 'caldav.event'
|
||||
__attribute__ = {
|
||||
'class' : None, # Use: O-1, Type: TEXT, Defines the access classification for a calendar component like "PUBLIC" / "PRIVATE" / "CONFIDENTIAL"
|
||||
'created' : None, # Use: O-1, Type: DATE-TIME, Specifies the date and time that the calendar information was created by the calendar user agent in the calendar store.
|
||||
'description' : None, # Use: O-1, Type: TEXT, Provides a more complete description of the calendar component, than that provided by the "SUMMARY" property.
|
||||
'dtstart' : None, # Use: O-1, Type: DATE-TIME, Specifies when the calendar component begins.
|
||||
'geo' : None, # Use: O-1, Type: FLOAT, Specifies information related to the global position for the activity specified by a calendar component.
|
||||
'last-mod' : None, # Use: O-1, Type: DATE-TIME Specifies the date and time that the information associated with the calendar component was last revised in the calendar store.
|
||||
'location' : None, # Use: O-1, Type: TEXT Defines the intended venue for the activity defined by a calendar component.
|
||||
'organizer' : None, # Use: O-1, Type: CAL-ADDRESS, Defines the organizer for a calendar component.
|
||||
'priority' : None, # Use: O-1, Type: INTEGER, Defines the relative priority for a calendar component.
|
||||
'dtstamp' : None, # Use: O-1, Type: DATE-TIME, Indicates the date/time that the instance of the iCalendar object was created.
|
||||
'seq' : None, # Use: O-1, Type: INTEGER, Defines the revision sequence number of the calendar component within a sequence of revision.
|
||||
'status' : None, # Use: O-1, Type: TEXT, Defines the overall status or confirmation for the calendar component.
|
||||
'summary' : None, # Use: O-1, Type: TEXT, Defines a short summary or subject for the calendar component.
|
||||
'transp' : None, # Use: O-1, Type: TEXT, Defines whether an event is transparent or not to busy time searches.
|
||||
'uid' : None, # Use: O-1, Type: TEXT, Defines the persistent, globally unique identifier for the calendar component.
|
||||
'url' : None, # Use: O-1, Type: URL, Defines a Uniform Resource Locator (URL) associated with the iCalendar object.
|
||||
'recurid' : None,
|
||||
'attach' : None, # Use: O-n, Type: BINARY, Provides the capability to associate a document object with a calendar component.
|
||||
'attendee' : None, # Use: O-n, Type: CAL-ADDRESS, Defines an "Attendee" within a calendar component.
|
||||
'categories' : None, # Use: O-n, Type: TEXT, Defines the categories for a calendar component.
|
||||
'comment' : None, # Use: O-n, Type: TEXT, Specifies non-processing information intended to provide a comment to the calendar user.
|
||||
'contact' : None, # Use: O-n, Type: TEXT, Used to represent contact information or alternately a reference to contact information associated with the calendar component.
|
||||
'exdate' : None, # Use: O-n, Type: DATE-TIME, Defines the list of date/time exceptions for a recurring calendar component.
|
||||
'exrule' : None, # Use: O-n, Type: RECUR, Defines a rule or repeating pattern for an exception to a recurrence set.
|
||||
'rstatus' : None,
|
||||
'related' : None, # Use: O-n, Specify the relationship of the alarm trigger with respect to the start or end of the calendar component.
|
||||
# like A trigger set 5 minutes after the end of the event or to-do.---> TRIGGER;RELATED=END:PT5M
|
||||
'resources' : None, # Use: O-n, Type: TEXT, Defines the equipment or resources anticipated for an activity specified by a calendar entity like RESOURCES:EASEL,PROJECTOR,VCR, LANGUAGE=fr:1 raton-laveur
|
||||
'rdate' : None, # Use: O-n, Type: DATE-TIME, Defines the list of date/times for a recurrence set.
|
||||
'rrule' : None, # Use: O-n, Type: RECUR, Defines a rule or repeating pattern for recurring events, to-dos, or time zone definitions.
|
||||
'x-prop' : None,
|
||||
'duration' : None, # Use: O-1, Type: DURATION, Specifies a positive duration of time.
|
||||
'dtend' : None, # Use: O-1, Type: DATE-TIME, Specifies the date and time that a calendar component ends.
|
||||
'class': None, # Use: O-1, Type: TEXT, Defines the access classification for a calendar component like "PUBLIC" / "PRIVATE" / "CONFIDENTIAL"
|
||||
'created': None, # Use: O-1, Type: DATE-TIME, Specifies the date and time that the calendar information was created by the calendar user agent in the calendar store.
|
||||
'description': None, # Use: O-1, Type: TEXT, Provides a more complete description of the calendar component, than that provided by the "SUMMARY" property.
|
||||
'dtstart': None, # Use: O-1, Type: DATE-TIME, Specifies when the calendar component begins.
|
||||
'geo': None, # Use: O-1, Type: FLOAT, Specifies information related to the global position for the activity specified by a calendar component.
|
||||
'last-mod': None, # Use: O-1, Type: DATE-TIME Specifies the date and time that the information associated with the calendar component was last revised in the calendar store.
|
||||
'location': None, # Use: O-1, Type: TEXT Defines the intended venue for the activity defined by a calendar component.
|
||||
'organizer': None, # Use: O-1, Type: CAL-ADDRESS, Defines the organizer for a calendar component.
|
||||
'priority': None, # Use: O-1, Type: INTEGER, Defines the relative priority for a calendar component.
|
||||
'dtstamp': None, # Use: O-1, Type: DATE-TIME, Indicates the date/time that the instance of the iCalendar object was created.
|
||||
'seq': None, # Use: O-1, Type: INTEGER, Defines the revision sequence number of the calendar component within a sequence of revision.
|
||||
'status': None, # Use: O-1, Type: TEXT, Defines the overall status or confirmation for the calendar component.
|
||||
'summary': None, # Use: O-1, Type: TEXT, Defines a short summary or subject for the calendar component.
|
||||
'transp': None, # Use: O-1, Type: TEXT, Defines whether an event is transparent or not to busy time searches.
|
||||
'uid': None, # Use: O-1, Type: TEXT, Defines the persistent, globally unique identifier for the calendar component.
|
||||
'url': None, # Use: O-1, Type: URL, Defines a Uniform Resource Locator (URL) associated with the iCalendar object.
|
||||
'recurid': None,
|
||||
'attach': None, # Use: O-n, Type: BINARY, Provides the capability to associate a document object with a calendar component.
|
||||
'attendee': None, # Use: O-n, Type: CAL-ADDRESS, Defines an "Attendee" within a calendar component.
|
||||
'categories': None, # Use: O-n, Type: TEXT, Defines the categories for a calendar component.
|
||||
'comment': None, # Use: O-n, Type: TEXT, Specifies non-processing information intended to provide a comment to the calendar user.
|
||||
'contact': None, # Use: O-n, Type: TEXT, Used to represent contact information or alternately a reference to contact information associated with the calendar component.
|
||||
'exdate': None, # Use: O-n, Type: DATE-TIME, Defines the list of date/time exceptions for a recurring calendar component.
|
||||
'exrule': None, # Use: O-n, Type: RECUR, Defines a rule or repeating pattern for an exception to a recurrence set.
|
||||
'rstatus': None,
|
||||
'related': None, # Use: O-n, Specify the relationship of the alarm trigger with respect to the start or end of the calendar component.
|
||||
# like A trigger set 5 minutes after the end of the event or to-do.---> TRIGGER;RELATED=END:PT5M
|
||||
'resources': None, # Use: O-n, Type: TEXT, Defines the equipment or resources anticipated for an activity specified by a calendar entity like RESOURCES:EASEL,PROJECTOR,VCR, LANGUAGE=fr:1 raton-laveur
|
||||
'rdate': None, # Use: O-n, Type: DATE-TIME, Defines the list of date/times for a recurrence set.
|
||||
'rrule': None, # Use: O-n, Type: RECUR, Defines a rule or repeating pattern for recurring events, to-dos, or time zone definitions.
|
||||
'x-prop': None,
|
||||
'duration': None, # Use: O-1, Type: DURATION, Specifies a positive duration of time.
|
||||
'dtend': None, # Use: O-1, Type: DATE-TIME, Specifies the date and time that a calendar component ends.
|
||||
}
|
||||
|
||||
def get_recurrent_dates(self, rrulestring, exdate, startdate=None):
|
||||
@@ -251,28 +215,11 @@ class Event(CalDAV, osv.osv_memory):
|
||||
rset1 = rrulestr(rrulestring, dtstart=startdate, forceset=True)
|
||||
for date in exdate:
|
||||
datetime_obj = datetime.strptime(date, "%Y-%m-%d %H:%M:%S")
|
||||
# datetime_obj_utc = datetime_obj.replace(tzinfo=timezone('UTC'))
|
||||
rset1._exdate.append(datetime_obj)
|
||||
re_dates = rset1._iter()
|
||||
recurrent_dates = map(lambda x:x.strftime('%Y-%m-%d %H:%M:%S'), re_dates)
|
||||
return recurrent_dates
|
||||
|
||||
def search(self, cr, uid, args, offset=0, limit=None, order=None,
|
||||
context=None, count=False):
|
||||
# put logic for recurrent event
|
||||
# example : 123-20091111170822
|
||||
pass
|
||||
|
||||
def create(self, cr, uid, vals, context={}):
|
||||
# put logic for recurrent event
|
||||
# example : 123-20091111170822
|
||||
pass
|
||||
|
||||
def write(self, cr, uid, ids, vals, context={}):
|
||||
# put logic for recurrent event
|
||||
# # example : 123-20091111170822
|
||||
pass
|
||||
|
||||
Event()
|
||||
|
||||
class ToDo(CalDAV):
|
||||
@@ -285,49 +232,47 @@ class Journal(CalDAV):
|
||||
|
||||
class FreeBusy(CalDAV):
|
||||
__attribute__ = {
|
||||
'contact' : None, # Use: O-1, Type: Text, Represent contact information or alternately a reference to contact information associated with the calendar component.
|
||||
'dtstart' : None, # Use: O-1, Type: DATE-TIME, Specifies when the calendar component begins.
|
||||
'dtend' : None, # Use: O-1, Type: DATE-TIME, Specifies the date and time that a calendar component ends.
|
||||
'duration' : None, # Use: O-1, Type: DURATION, Specifies a positive duration of time.
|
||||
'dtstamp' : None, # Use: O-1, Type: DATE-TIME, Indicates the date/time that the instance of the iCalendar object was created.
|
||||
'organizer' : None, # Use: O-1, Type: CAL-ADDRESS, Defines the organizer for a calendar component.
|
||||
'uid' : None, # Use: O-1, Type: Text, Defines the persistent, globally unique identifier for the calendar component.
|
||||
'url' : None, # Use: O-1, Type: URL, Defines a Uniform Resource Locator (URL) associated with the iCalendar object.
|
||||
'attendee' : None, # Use: O-n, Type: CAL-ADDRESS, Defines an "Attendee" within a calendar component.
|
||||
'comment' : None, # Use: O-n, Type: TEXT, Specifies non-processing information intended to provide a comment to the calendar user.
|
||||
'freebusy' : None, # Use: O-n, Type: PERIOD, Defines one or more free or busy time intervals.
|
||||
'rstatus' : None,
|
||||
'X-prop' : None,
|
||||
'contact': None, # Use: O-1, Type: Text, Represent contact information or alternately a reference to contact information associated with the calendar component.
|
||||
'dtstart': None, # Use: O-1, Type: DATE-TIME, Specifies when the calendar component begins.
|
||||
'dtend': None, # Use: O-1, Type: DATE-TIME, Specifies the date and time that a calendar component ends.
|
||||
'duration': None, # Use: O-1, Type: DURATION, Specifies a positive duration of time.
|
||||
'dtstamp': None, # Use: O-1, Type: DATE-TIME, Indicates the date/time that the instance of the iCalendar object was created.
|
||||
'organizer': None, # Use: O-1, Type: CAL-ADDRESS, Defines the organizer for a calendar component.
|
||||
'uid': None, # Use: O-1, Type: Text, Defines the persistent, globally unique identifier for the calendar component.
|
||||
'url': None, # Use: O-1, Type: URL, Defines a Uniform Resource Locator (URL) associated with the iCalendar object.
|
||||
'attendee': None, # Use: O-n, Type: CAL-ADDRESS, Defines an "Attendee" within a calendar component.
|
||||
'comment': None, # Use: O-n, Type: TEXT, Specifies non-processing information intended to provide a comment to the calendar user.
|
||||
'freebusy': None, # Use: O-n, Type: PERIOD, Defines one or more free or busy time intervals.
|
||||
'rstatus': None,
|
||||
'X-prop': None,
|
||||
}
|
||||
|
||||
|
||||
class Timezone(CalDAV):
|
||||
__attribute__ = {
|
||||
'tzid' : None, # Use: R-1, Type: Text, Specifies the text value that uniquely identifies the "VTIMEZONE" calendar component.
|
||||
'last-mod' : None, # Use: O-1, Type: DATE-TIME, Specifies the date and time that the information associated with the calendar component was last revised in the calendar store.
|
||||
'tzurl' : None, # Use: O-1, Type: URI, Provides a means for a VTIMEZONE component to point to a network location that can be used to retrieve an up-to-date version of itself.
|
||||
'standardc' : # Use: R-n,
|
||||
{'tzprop' : None, }, # Use: R-1,
|
||||
'daylightc' : # Use: R-n, Type: Text,
|
||||
{'tzprop' : None, }, # Use: R-1,
|
||||
'x-prop' : None, # Use: O-n, Type: Text,
|
||||
'tzid': None, # Use: R-1, Type: Text, Specifies the text value that uniquely identifies the "VTIMEZONE" calendar component.
|
||||
'last-mod': None, # Use: O-1, Type: DATE-TIME, Specifies the date and time that the information associated with the calendar component was last revised in the calendar store.
|
||||
'tzurl': None, # Use: O-1, Type: URI, Provides a means for a VTIMEZONE component to point to a network location that can be used to retrieve an up-to-date version of itself.
|
||||
'standardc': # Use: R-n,
|
||||
{'tzprop': None, }, # Use: R-1,
|
||||
'daylightc': # Use: R-n, Type: Text,
|
||||
{'tzprop': None, }, # Use: R-1,
|
||||
'x-prop': None, # Use: O-n, Type: Text,
|
||||
}
|
||||
def import_ical(self, cr, uid, ical_data):
|
||||
for val in ical_data.getChildren():
|
||||
if self.__attribute__.has_key(val.name.lower()):
|
||||
self.__attribute__[val.name] = val.value
|
||||
|
||||
|
||||
class Alarm(CalDAV, osv.osv_memory):
|
||||
_name = 'caldav.alarm'
|
||||
__attribute__ = {
|
||||
'action' : None, # Use: R-1, Type: Text, defines the action to be invoked when an alarm is triggered LIKE "AUDIO" / "DISPLAY" / "EMAIL" / "PROCEDURE"
|
||||
'description' : None, # Type: Text, Provides a more complete description of the calendar component, than that provided by the "SUMMARY" property. Use:- R-1 for DISPLAY,Use:- R-1 for EMAIL,Use:- R-1 for PROCEDURE
|
||||
'summary' : None, # Use: R-1, Type: Text Which contains the text to be used as the message subject. Use for EMAIL
|
||||
'attendee' : None, # Use: R-n, Type: CAL-ADDRESS, Contain the email address of attendees to receive the message. It can also include one or more. Use for EMAIL
|
||||
'trigger' : None, # Use: R-1, Type: DURATION, The "TRIGGER" property specifies a duration prior to the start of an event or a to-do. The "TRIGGER" edge may be explicitly set to be relative to the "START" or "END" of the event or to-do with the "RELATED" parameter of the "TRIGGER" property. The "TRIGGER" property value type can alternatively be set to an absolute calendar date and time of day value. Use for all action like AUDIO, DISPLAY, EMAIL and PROCEDURE
|
||||
'duration' : None, # Type: DURATION, Duration' and 'repeat' are both optional, and MUST NOT occur more than once each, but if one occurs, so MUST the other. Use:- 0-1 for AUDIO, EMAIL and PROCEDURE, Use:- 0-n for DISPLAY
|
||||
'repeat' : None, # Type: INTEGER, Duration' and 'repeat' are both optional, and MUST NOT occur more than once each, but if one occurs, so MUST the other. Use:- 0-1 for AUDIO, EMAIL and PROCEDURE, Use:- 0-n for DISPLAY
|
||||
'attach' : None, # Use:- O-n : which MUST point to a sound resource, which is rendered when the alarm is triggered for AUDIO, Use:- O-n : which are intended to be sent as message attachments for EMAIL, Use:- R-1:which MUST point to a procedure resource, which is invoked when the alarm is triggered for PROCEDURE.
|
||||
'x-prop' : None,
|
||||
'action': None, # Use: R-1, Type: Text, defines the action to be invoked when an alarm is triggered LIKE "AUDIO" / "DISPLAY" / "EMAIL" / "PROCEDURE"
|
||||
'description': None, # Type: Text, Provides a more complete description of the calendar component, than that provided by the "SUMMARY" property. Use:- R-1 for DISPLAY,Use:- R-1 for EMAIL,Use:- R-1 for PROCEDURE
|
||||
'summary': None, # Use: R-1, Type: Text Which contains the text to be used as the message subject. Use for EMAIL
|
||||
'attendee': None, # Use: R-n, Type: CAL-ADDRESS, Contain the email address of attendees to receive the message. It can also include one or more. Use for EMAIL
|
||||
'trigger': None, # Use: R-1, Type: DURATION, The "TRIGGER" property specifies a duration prior to the start of an event or a to-do. The "TRIGGER" edge may be explicitly set to be relative to the "START" or "END" of the event or to-do with the "RELATED" parameter of the "TRIGGER" property. The "TRIGGER" property value type can alternatively be set to an absolute calendar date and time of day value. Use for all action like AUDIO, DISPLAY, EMAIL and PROCEDURE
|
||||
'duration': None, # Type: DURATION, Duration' and 'repeat' are both optional, and MUST NOT occur more than once each, but if one occurs, so MUST the other. Use:- 0-1 for AUDIO, EMAIL and PROCEDURE, Use:- 0-n for DISPLAY
|
||||
'repeat': None, # Type: INTEGER, Duration' and 'repeat' are both optional, and MUST NOT occur more than once each, but if one occurs, so MUST the other. Use:- 0-1 for AUDIO, EMAIL and PROCEDURE, Use:- 0-n for DISPLAY
|
||||
'attach': None, # Use:- O-n: which MUST point to a sound resource, which is rendered when the alarm is triggered for AUDIO, Use:- O-n: which are intended to be sent as message attachments for EMAIL, Use:- R-1:which MUST point to a procedure resource, which is invoked when the alarm is triggered for PROCEDURE.
|
||||
'x-prop': None,
|
||||
}
|
||||
|
||||
def import_ical(self, cr, uid, ical_data):
|
||||
@@ -336,25 +281,25 @@ class Alarm(CalDAV, osv.osv_memory):
|
||||
seconds = child.value.seconds
|
||||
days = child.value.days
|
||||
diff = (days * 86400) + seconds
|
||||
duration = 'DAYS'
|
||||
interval = 'DAYS'
|
||||
related = 'BEFORE'
|
||||
if not seconds:
|
||||
interval = abs(days)
|
||||
duration = abs(days)
|
||||
related = days>0 and 'AFTER' or 'BEFORE'
|
||||
elif (abs(diff) / 3600) == 0:
|
||||
interval = abs(diff / 60)
|
||||
duration = 'MINUTES'
|
||||
duration = abs(diff / 60)
|
||||
interval = 'MINUTES'
|
||||
related = days>=0 and 'AFTER' or 'BEFORE'
|
||||
else:
|
||||
interval = abs(diff / 3600)
|
||||
duration = 'HOURS'
|
||||
duration = abs(diff / 3600)
|
||||
interval = 'HOURS'
|
||||
related = days>=0 and 'AFTER' or 'BEFORE'
|
||||
self.ical_set('trigger_interval', interval, 'value')
|
||||
self.ical_set('trigger_duration', duration, 'value')
|
||||
self.ical_set('trigger_related', related, 'value')
|
||||
self.ical_set('trigger_occurs', related, 'value')
|
||||
if child.params:
|
||||
if child.params.get('RELATED'):
|
||||
self.ical_set('trigger_occurs', child.params.get('RELATED')[0].lower(), 'value')
|
||||
self.ical_set('trigger_related', child.params.get('RELATED')[0].lower(), 'value')
|
||||
else:
|
||||
self.ical_set(child.name.lower(), child.value, 'value')
|
||||
vals = map_data(cr, uid, self)
|
||||
@@ -365,17 +310,17 @@ Alarm()
|
||||
class Attendee(CalDAV, osv.osv_memory):
|
||||
_name = 'caldav.attendee'
|
||||
__attribute__ = {
|
||||
'cutype' : None, # Use: 0-1 Specify the type of calendar user specified by the property like "INDIVIDUAL"/"GROUP"/"RESOURCE"/"ROOM"/"UNKNOWN".
|
||||
'member' : None, # Use: 0-1 Specify the group or list membership of the calendar user specified by the property.
|
||||
'role' : None, # Use: 0-1 Specify the participation role for the calendar user specified by the property like "CHAIR"/"REQ-PARTICIPANT"/"OPT-PARTICIPANT"/"NON-PARTICIPANT"
|
||||
'partstat' : None, # Use: 0-1 Specify the participation status for the calendar user specified by the property. like use for VEVENT :- "NEEDS-ACTION"/"ACCEPTED"/"DECLINED"/"TENTATIVE"/"DELEGATED", use for VTODO :-"NEEDS-ACTION"/"ACCEPTED"/"DECLINED"/"TENTATIVE"/"DELEGATED"/"COMPLETED"/"IN-PROCESS" and use for VJOURNAL :- "NEEDS-ACTION"/"ACCEPTED"/"DECLINED".
|
||||
'rsvp' : None, # Use: 0-1 Specify whether there is an expectation of a favor of a reply from the calendar user specified by the property value like TRUE / FALSE.
|
||||
'delegated-to' : None, # Use: 0-1 Specify the calendar users to whom the calendar user specified by the property has delegated participation.
|
||||
'delegated-from' : None, # Use: 0-1 Specify the calendar users that have delegated their participation to the calendar user specified by the property.
|
||||
'sent-by' : None, # Use: 0-1 Specify the calendar user that is acting on behalf of the calendar user specified by the property.
|
||||
'cn' : None, # Use: 0-1 Specify the common name to be associated with the calendar user specified by the property.
|
||||
'dir' : None, # Use: 0-1 Specify reference to a directory entry associated with the calendar user specified by the property.
|
||||
'language' : None, # Use: 0-1 Specify the language for text values in a property or property parameter.
|
||||
'cutype': None, # Use: 0-1 Specify the type of calendar user specified by the property like "INDIVIDUAL"/"GROUP"/"RESOURCE"/"ROOM"/"UNKNOWN".
|
||||
'member': None, # Use: 0-1 Specify the group or list membership of the calendar user specified by the property.
|
||||
'role': None, # Use: 0-1 Specify the participation role for the calendar user specified by the property like "CHAIR"/"REQ-PARTICIPANT"/"OPT-PARTICIPANT"/"NON-PARTICIPANT"
|
||||
'partstat': None, # Use: 0-1 Specify the participation status for the calendar user specified by the property. like use for VEVENT:- "NEEDS-ACTION"/"ACCEPTED"/"DECLINED"/"TENTATIVE"/"DELEGATED", use for VTODO:-"NEEDS-ACTION"/"ACCEPTED"/"DECLINED"/"TENTATIVE"/"DELEGATED"/"COMPLETED"/"IN-PROCESS" and use for VJOURNAL:- "NEEDS-ACTION"/"ACCEPTED"/"DECLINED".
|
||||
'rsvp': None, # Use: 0-1 Specify whether there is an expectation of a favor of a reply from the calendar user specified by the property value like TRUE / FALSE.
|
||||
'delegated-to': None, # Use: 0-1 Specify the calendar users to whom the calendar user specified by the property has delegated participation.
|
||||
'delegated-from': None, # Use: 0-1 Specify the calendar users that have delegated their participation to the calendar user specified by the property.
|
||||
'sent-by': None, # Use: 0-1 Specify the calendar user that is acting on behalf of the calendar user specified by the property.
|
||||
'cn': None, # Use: 0-1 Specify the common name to be associated with the calendar user specified by the property.
|
||||
'dir': None, # Use: 0-1 Specify reference to a directory entry associated with the calendar user specified by the property.
|
||||
'language': None, # Use: 0-1 Specify the language for text values in a property or property parameter.
|
||||
}
|
||||
|
||||
def import_ical(self, cr, uid, ical_data):
|
||||
|
||||
@@ -54,10 +54,10 @@
|
||||
<separator string="Description" colspan="4"/>
|
||||
<field name="description" colspan="4" nolabel="1" attrs="{'required' : [('action','in',('EMAIL'))]}"/>
|
||||
<group string="Reminder details" col="4" colspan="4">
|
||||
<field name="trigger_interval" nolabel="1" select="1"/>
|
||||
<field name="trigger_duration" nolabel="1" select="1"/>
|
||||
<field name="trigger_related" nolabel="1" select="1"/>
|
||||
<field name="trigger_interval" nolabel="1" select="1"/>
|
||||
<field name="trigger_occurs" nolabel="1" select="1"/>
|
||||
<field name="trigger_related" nolabel="1" select="1"/>
|
||||
</group>
|
||||
<field name="duration"/>
|
||||
<field name="repeat"/>
|
||||
|
||||
+23
-52
@@ -92,7 +92,7 @@ class crm_caldav_alarm(osv.osv):
|
||||
'description': {'field': 'name', 'type': 'text'},
|
||||
'summary': {'field': 'description', 'type': 'text'},
|
||||
'attendee': {'field': 'attendee', 'type': 'text'},
|
||||
'trigger_related': {'field': 'trigger_related', 'type': 'text'}, # Check with separated fields
|
||||
'trigger_related': {'field': 'trigger_related', 'type': 'text'},
|
||||
'trigger_duration': {'field': 'trigger_duration', 'type': 'text'},
|
||||
'trigger_occurs': {'field': 'trigger_occurs', 'type': 'text'},
|
||||
'trigger_interval': {'field': 'trigger_interval', 'type': 'text'},
|
||||
@@ -108,12 +108,12 @@ class crm_caldav_alarm(osv.osv):
|
||||
'description' : fields.text('Description'),
|
||||
'attendee': fields.many2many('crm.caldav.attendee', 'alarm_attendee_rel', \
|
||||
'alarm_id', 'attendee_id', 'Attendees'),
|
||||
'trigger_related' : fields.selection([('BEFORE', 'BEFORE'), ('AFTER', 'AFTER')]\
|
||||
'trigger_occurs' : fields.selection([('BEFORE', 'BEFORE'), ('AFTER', 'AFTER')]\
|
||||
, 'Trigger time', required=True),
|
||||
'trigger_duration' : fields.selection([('MINUTES', 'MINUTES'), ('HOURS', 'HOURS'), \
|
||||
'trigger_interval' : fields.selection([('MINUTES', 'MINUTES'), ('HOURS', 'HOURS'), \
|
||||
('DAYS', 'DAYS')], 'Trugger duration', required=True),
|
||||
'trigger_interval' : fields.integer('TIme' , required=True),
|
||||
'trigger_occurs' : fields.selection([('starts', 'The event starts'), ('end', \
|
||||
'trigger_duration' : fields.integer('TIme' , required=True),
|
||||
'trigger_related' : fields.selection([('starts', 'The event starts'), ('end', \
|
||||
'The event ends')], 'Trigger Occures at', required=True),
|
||||
'duration' : fields.integer('Duration'),
|
||||
'repeat' : fields.integer('Repeat'), # TODO
|
||||
@@ -123,10 +123,10 @@ class crm_caldav_alarm(osv.osv):
|
||||
|
||||
_defaults = {
|
||||
'action' : lambda *x: 'EMAIL',
|
||||
'trigger_interval' : lambda *x: 5,
|
||||
'trigger_duration' : lambda *x: 'MINUTES',
|
||||
'trigger_related' : lambda *x: 'BEFORE',
|
||||
'trigger_occurs' : lambda *x: 'starts',
|
||||
'trigger_interval' : lambda *x: 'MINUTES',
|
||||
'trigger_duration' : lambda *x: 5,
|
||||
'trigger_occurs' : lambda *x: 'BEFORE',
|
||||
'trigger_related' : lambda *x: 'starts',
|
||||
}
|
||||
|
||||
crm_caldav_alarm()
|
||||
@@ -268,49 +268,21 @@ class crm_case(osv.osv):
|
||||
|
||||
def export_cal(self, cr, uid, ids, context={}):
|
||||
crm_data = self.read(cr, uid, ids, [], context ={'read' :True})
|
||||
ical = vobject.iCalendar()
|
||||
event_obj = self.pool.get('caldav.event')
|
||||
uid_val = ''
|
||||
for crm in crm_data:
|
||||
vevent = ical.add('vevent')
|
||||
for key, val in self.__attribute__.items():
|
||||
if key == 'uid':
|
||||
uid_val += str(crm[val['field']])
|
||||
continue
|
||||
if val == None or key == 'rrule' or not val.has_key('field') or not crm[val['field']]:
|
||||
continue
|
||||
if key == "attendee":
|
||||
attendee_object = self.pool.get('crm.caldav.attendee')
|
||||
for attendee in attendee_object.read(cr, uid, crm[val['field']], []):
|
||||
attendee_add = vevent.add('attendee')
|
||||
for a_key, a_val in attendee_object.__attribute__.items():
|
||||
if attendee[a_val['field']]:
|
||||
if a_val['type'] == 'text':
|
||||
attendee_add.params[a_key] = [str(attendee[a_val['field']])]
|
||||
elif a_val['type'] == 'boolean':
|
||||
attendee_add.params[a_key] = [str(attendee[a_val['field']])]
|
||||
|
||||
elif val.has_key('sub-field'):
|
||||
vevent.add(key).value = crm[val['field']][1]
|
||||
elif val.has_key('mapping'):
|
||||
for key1, val1 in val['mapping'].items():
|
||||
if val1 == crm[val['field']]:
|
||||
vevent.add(key).value = key1
|
||||
else:
|
||||
if val['type'] == "text":
|
||||
vevent.add(key).value = str(crm[val['field']])
|
||||
elif val['type'] == 'datetime' and crm[val['field']]:
|
||||
vevent.add(key).value = datetime.datetime.strptime(crm[val['field']], \
|
||||
"%Y-%m-%d %H:%M:%S")
|
||||
if crm[self.__attribute__['rrule']['field']]:
|
||||
startdate = datetime.datetime.strptime(crm['date'], "%Y-%m-%d %H:%M:%S")
|
||||
if not startdate:
|
||||
startdate = datetime.now()
|
||||
rset1 = rrulestr(str(crm[self.__attribute__['rrule']['field']]), \
|
||||
dtstart=startdate, forceset=True)
|
||||
vevent.rruleset = rset1
|
||||
vevent.add('uid').value = uid_val
|
||||
return ical.serialize()#.replace(vobject.icalendar.CRLF, vobject.icalendar.LF).strip()
|
||||
event_obj.__attribute__.update(self.__attribute__)
|
||||
|
||||
attendee_obj = self.pool.get('caldav.attendee')
|
||||
crm_attendee = self.pool.get('crm.caldav.attendee')
|
||||
attendee_obj.__attribute__.update(crm_attendee.__attribute__)
|
||||
|
||||
alarm_obj = self.pool.get('caldav.alarm')
|
||||
crm_alarm = self.pool.get('crm.caldav.alarm')
|
||||
alarm_obj.__attribute__.update(crm_alarm.__attribute__)
|
||||
|
||||
ical = event_obj.export_ical(cr, uid, crm_data)
|
||||
caendar_val = ical.serialize()
|
||||
caendar_val = caendar_val.replace('"', '').strip()
|
||||
return caendar_val
|
||||
|
||||
def import_cal(self, cr, uid, ids, data, context={}):
|
||||
file_content = base64.decodestring(data['form']['file_path'])
|
||||
@@ -502,7 +474,6 @@ class virtual_report_spool(web_services.report_spool):
|
||||
virtual_report_spool()
|
||||
|
||||
class virtual_wizard(web_services.wizard):
|
||||
|
||||
def exp_execute(self, db, uid, wiz_id, datas, action='init', context=None):
|
||||
new_ids = []
|
||||
if 'id' in datas:
|
||||
|
||||
Reference in New Issue
Block a user