From 6164d129ab39fb51db558049315906776d9837c2 Mon Sep 17 00:00:00 2001 From: "rpa (Open ERP)" Date: Fri, 13 Aug 2010 12:06:27 +0530 Subject: [PATCH 1/5] [FIX]: caldav: Keep event specific timezone on import instead of User timezone bzr revid: rpa@tinyerp.com-20100813063627-cq3qcznxf5ghupg4 --- addons/caldav/calendar.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/addons/caldav/calendar.py b/addons/caldav/calendar.py index fd533c098a1..37224fb2f50 100644 --- a/addons/caldav/calendar.py +++ b/addons/caldav/calendar.py @@ -266,11 +266,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) From d5a380906e3714c213df2c899fe14d6e05331d0a Mon Sep 17 00:00:00 2001 From: "rpa (Open ERP)" Date: Fri, 13 Aug 2010 14:26:50 +0530 Subject: [PATCH 2/5] [FIX]: base_calendar: Minor fix for editing recurrent events bzr revid: rpa@tinyerp.com-20100813085650-01t3yqyvowvy68m7 --- addons/base_calendar/base_calendar.py | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/base_calendar/base_calendar.py b/addons/base_calendar/base_calendar.py index 7bb7d61d8ee..9421922bb50 100644 --- a/addons/base_calendar/base_calendar.py +++ b/addons/base_calendar/base_calendar.py @@ -1441,6 +1441,7 @@ 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) vals.update({ 'recurrent_uid': real_event_id, 'recurrent_id': data.get('date'), From c471c638417c5cb60f83e3ee2f0402baad42cde3 Mon Sep 17 00:00:00 2001 From: "rpa (Open ERP)" Date: Fri, 13 Aug 2010 16:10:38 +0530 Subject: [PATCH 3/5] [IMP]: base_calendar: Minor Improvements bzr revid: rpa@tinyerp.com-20100813104038-rup33spnnn218xuh --- addons/base_calendar/base_calendar.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/base_calendar/base_calendar.py b/addons/base_calendar/base_calendar.py index 9421922bb50..eaaa75bbd6e 100644 --- a/addons/base_calendar/base_calendar.py +++ b/addons/base_calendar/base_calendar.py @@ -1441,14 +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) - vals.update({ + data.update(vals) + 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) + 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: From 20b96b8f61e0e0543e6bf07dcec9e32a2d4b2fe9 Mon Sep 17 00:00:00 2001 From: "rpa (Open ERP)" Date: Fri, 13 Aug 2010 18:31:05 +0530 Subject: [PATCH 4/5] [IMP]: base_calendar: Minor Improvements bzr revid: rpa@tinyerp.com-20100813130105-mqsvc3d2q7hj1vlc --- addons/base_calendar/base_calendar.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/base_calendar/base_calendar.py b/addons/base_calendar/base_calendar.py index eaaa75bbd6e..a0d578dffce 100644 --- a/addons/base_calendar/base_calendar.py +++ b/addons/base_calendar/base_calendar.py @@ -1441,13 +1441,13 @@ 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'): - data.update(vals) data.update({ 'recurrent_uid': real_event_id, 'recurrent_id': data.get('date'), 'rrule_type': 'none', 'rrule': '' }) + 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 From cf80c1d74ab4a1c0fa59dc3850b77e3006aad84a Mon Sep 17 00:00:00 2001 From: "rpa (Open ERP)" Date: Mon, 16 Aug 2010 16:29:16 +0530 Subject: [PATCH 5/5] [FIX]: caldav: Fixed problem of importing recurrent event from sunbird when we edit one bzr revid: rpa@tinyerp.com-20100816105916-152tcfm6jynt6spi --- addons/caldav/calendar.py | 20 ++++++++++++++++---- addons/crm_caldav/crm_caldav.py | 21 ++++++++++++++------- 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/addons/caldav/calendar.py b/addons/caldav/calendar.py index 3047441834a..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) @@ -454,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: @@ -472,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)