[IMP]: caldav, crm: Improvement for importing recurrent meetings with same uid

bzr revid: rpa@openerp.co.in-20100118110730-c57780xdyjyug6by
This commit is contained in:
rpa (Open ERP)
2010-01-18 16:37:30 +05:30
parent bbe8e201ba
commit b034fc865d
2 changed files with 21 additions and 9 deletions
+12 -5
View File
@@ -51,19 +51,26 @@ def real_id2caldav_id(real_id, recurrent_date):
return '%d-%s'%(real_id, recurrent_date)
return real_id
def uid2openobjectid(cr, uidval, oomodel):
def uid2openobjectid(cr, uidval, oomodel, rdate):
__rege = re.compile(r'OpenObject-([\w|\.]+)_([0-9]+)@(\w+)$')
wematch = __rege.match(uidval.encode('utf8'))
if not wematch:
return False
return (False, None)
else:
model, id, dbname = wematch.groups()
if (not model == oomodel) or (not dbname == cr.dbname):
return False
cr.execute('select distinct(id) from %s' % model.replace('.', '_'))
return (False, None)
qry = 'select distinct(id) from %s' % model.replace('.', '_')
if rdate:
qry += " where recurrent_id='%s'" % (rdate)
cr.execute(qry)
r_id = cr.fetchone()
if r_id:
return (id, r_id[0])
cr.execute(qry)
ids = map(lambda x: str(x[0]), cr.fetchall())
if id in ids:
return id
return (id, None)
return False
def openobjectid2uid(cr, uidval, oomodel):
+9 -4
View File
@@ -194,13 +194,18 @@ rule or repeating pattern for anexception to a recurrence set"),
vals = event_obj.import_ical(cr, uid, file_content)
ids = []
for val in vals:
is_exists = common.uid2openobjectid(cr, val['id'], self._name)
exists, r_id = common.uid2openobjectid(cr, val['id'], self._name, \
val.get('recurrent_id'))
if val.has_key('create_date'): val.pop('create_date')
val['caldav_url'] = context.get('url') or ''
val.pop('id')
if is_exists:
self.write(cr, uid, [is_exists], val)
ids.append(is_exists)
if exists and r_id:
val.update({'recurrent_uid': exists})
self.write(cr, uid, [r_id], val)
ids.append(r_id)
elif exists:
self.write(cr, uid, [exists], val)
ids.append(exists)
else:
case_id = self.create(cr, uid, val)
ids.append(case_id)