bzr revid: hmo@tinyerp.com-20100817053830-ao9cbtnj6l8oscft
This commit is contained in:
Harry (OpenERP)
2010-08-17 11:08:30 +05:30
3 changed files with 36 additions and 18 deletions
+3 -2
View File
@@ -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:
+19 -9
View File
@@ -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)
+14 -7
View File
@@ -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)