summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarry (OpenERP) <hmo@tinyerp.com>2010-08-17 11:08:30 +0530
committerHarry (OpenERP) <hmo@tinyerp.com>2010-08-17 11:08:30 +0530
commitc3a34ce07df576d0750f12d68a29c5d64c5c19dd (patch)
tree8d8a648fdffaaec1e99865295acd430542b734bc
parentcbea6a2d9a37b768b84716ca85849f17c7ebc827 (diff)
parentcf80c1d74ab4a1c0fa59dc3850b77e3006aad84a (diff)
[MERGE]
bzr revid: hmo@tinyerp.com-20100817053830-ao9cbtnj6l8oscft
-rw-r--r--addons/base_calendar/base_calendar.py5
-rw-r--r--addons/caldav/calendar.py28
-rw-r--r--addons/crm_caldav/crm_caldav.py21
3 files changed, 36 insertions, 18 deletions
diff --git a/addons/base_calendar/base_calendar.py b/addons/base_calendar/base_calendar.py
index 7bb7d61d8ee..a0d578dffce 100644
--- a/addons/base_calendar/base_calendar.py
+++ b/addons/base_calendar/base_calendar.py
@@ -1441,13 +1441,14 @@ true, it will allow you to hide the event alarm information without removing it.
data = self.read(cr, uid, event_id, ['date', 'date_deadline', \
'rrule', 'duration'])
if data.get('rrule'):
- vals.update({
+ data.update({
'recurrent_uid': real_event_id,
'recurrent_id': data.get('date'),
'rrule_type': 'none',
'rrule': ''
})
- new_id = self.copy(cr, uid, real_event_id, default=vals, context=context)
+ data.update(vals)
+ new_id = self.copy(cr, uid, real_event_id, default=data, context=context)
context.update({'active_id': new_id, 'active_ids': [new_id]})
continue
if not real_event_id in new_ids:
diff --git a/addons/caldav/calendar.py b/addons/caldav/calendar.py
index b4f7c03e5aa..07d12898684 100644
--- a/addons/caldav/calendar.py
+++ b/addons/caldav/calendar.py
@@ -75,9 +75,9 @@ def uid2openobjectid(cr, uidval, oomodel, rdate):
return (False, None)
def openobjectid2uid(cr, uidval, oomodel):
- """ Open Object Id To UId
+ """ Gives the value of UID for VEVENT
@param cr: the current row, from the database cursor,
- @param uidval: Get USerId vale
+ @param uidval: Id value of the Event
@oomodel: Open Object ModelName """
value = 'OpenObject-%s_%s@%s' % (oomodel, uidval, cr.dbname)
@@ -322,11 +322,9 @@ class CalDAV(object):
continue
if cal_data.name.lower() in self.__attribute__:
if cal_data.params.get('X-VOBJ-ORIGINAL-TZID'):
- # since we do convert, do we also need to save the original tzid?
- # self.ical_set('vtimezone', cal_data.params.get('X-VOBJ-ORIGINAL-TZID'), 'value')
-
- date_local = cal_data.value.astimezone(_server_tzinfo)
- self.ical_set(cal_data.name.lower(), date_local, 'value')
+ self.ical_set('vtimezone', cal_data.params.get('X-VOBJ-ORIGINAL-TZID'), 'value')
+ date_utc = cal_data.value.astimezone(pytz.utc)
+ self.ical_set(cal_data.name.lower(), date_utc, 'value')
continue
self.ical_set(cal_data.name.lower(), cal_data.value, 'value')
vals = map_data(cr, uid, self, context=context)
@@ -456,9 +454,16 @@ class CalDAV(object):
recur_pool = {}
try:
for val in vals:
- exists, r_id = uid2openobjectid(cr, val['id'], context.get('model'), \
+ # Compute value of duration
+ if 'date_deadline' in val and 'duration' not in val:
+ start = datetime.strptime(val['date'], '%Y-%m-%d %H:%M:%S')
+ end = datetime.strptime(val['date_deadline'], '%Y-%m-%d %H:%M:%S')
+ diff = end - start
+ val['duration'] = (diff.seconds/float(86400) + diff.days) * 24
+ exists, r_id = calendar.uid2openobjectid(cr, val['id'], context.get('model'), \
val.get('recurrent_id'))
- if val.has_key('create_date'): val.pop('create_date')
+ if val.has_key('create_date'):
+ val.pop('create_date')
u_id = val.get('id', None)
val.pop('id')
if exists and r_id:
@@ -474,6 +479,11 @@ class CalDAV(object):
revent_id = model_obj.create(cr, uid, val)
ids.append(revent_id)
else:
+ __rege = re.compile(r'OpenObject-([\w|\.]+)_([0-9]+)@(\w+)$')
+ wematch = __rege.match(u_id.encode('utf8'))
+ if wematch:
+ model, recur_id, dbname = wematch.groups()
+ val.update({'recurrent_uid': recur_id})
event_id = model_obj.create(cr, uid, val)
recur_pool[u_id] = event_id
ids.append(event_id)
diff --git a/addons/crm_caldav/crm_caldav.py b/addons/crm_caldav/crm_caldav.py
index a9430a47225..0d46a5429eb 100644
--- a/addons/crm_caldav/crm_caldav.py
+++ b/addons/crm_caldav/crm_caldav.py
@@ -23,6 +23,7 @@ from osv import fields, osv
from crm import crm
from caldav import calendar
from datetime import datetime
+import re
class crm_meeting(osv.osv):
_inherit = 'crm.meeting'
@@ -74,9 +75,16 @@ class crm_meeting(osv.osv):
recur_pool = {}
try:
for val in vals:
+ # Compute value of duration
+ if 'date_deadline' in val and 'duration' not in val:
+ start = datetime.strptime(val['date'], '%Y-%m-%d %H:%M:%S')
+ end = datetime.strptime(val['date_deadline'], '%Y-%m-%d %H:%M:%S')
+ diff = end - start
+ val['duration'] = (diff.seconds/float(86400) + diff.days) * 24
exists, r_id = calendar.uid2openobjectid(cr, val['id'], context.get('model'), \
val.get('recurrent_id'))
- if val.has_key('create_date'): val.pop('create_date')
+ if val.has_key('create_date'):
+ val.pop('create_date')
u_id = val.get('id', None)
val.pop('id')
if exists and r_id:
@@ -84,12 +92,6 @@ class crm_meeting(osv.osv):
model_obj.write(cr, uid, [r_id], val)
ids.append(r_id)
elif exists:
- # Compute value of duration
- if 'date_deadline' in val and 'duration' not in val:
- start = datetime.strptime(val['date'], '%Y-%m-%d %H:%M:%S')
- end = datetime.strptime(val['date_deadline'], '%Y-%m-%d %H:%M:%S')
- diff = end - start
- val['duration'] = (diff.seconds/float(86400) + diff.days) * 24
model_obj.write(cr, uid, [exists], val)
ids.append(exists)
else:
@@ -98,6 +100,11 @@ class crm_meeting(osv.osv):
revent_id = model_obj.create(cr, uid, val)
ids.append(revent_id)
else:
+ __rege = re.compile(r'OpenObject-([\w|\.]+)_([0-9]+)@(\w+)$')
+ wematch = __rege.match(u_id.encode('utf8'))
+ if wematch:
+ model, recur_id, dbname = wematch.groups()
+ val.update({'recurrent_uid': recur_id})
event_id = model_obj.create(cr, uid, val)
recur_pool[u_id] = event_id
ids.append(event_id)