[IMP]: caldav,crm,project_calendar: Created new function to map uid of ics in caldav and modification in crm and project related importing same ics file
bzr revid: rpa@tinyerp.com-20091224133549-qhhil3bgqx89srug
This commit is contained in:
+20
-3
@@ -24,15 +24,32 @@ from service import web_services
|
||||
from tools.translate import _
|
||||
import re
|
||||
|
||||
months = {1:"January", 2:"February", 3:"March", 4:"April", 5:"May", 6:"June", \
|
||||
7:"July", 8:"August", 9:"September", 10:"October", 11:"November", \
|
||||
12:"December"}
|
||||
|
||||
def caldevIDs2readIDs(caldev_ID = None):
|
||||
if caldev_ID:
|
||||
if isinstance(caldev_ID, str):
|
||||
return int(caldev_ID.split('-')[0])
|
||||
return caldev_ID
|
||||
|
||||
months = {1:"January", 2:"February", 3:"March", 4:"April", 5:"May", 6:"June", \
|
||||
7:"July", 8:"August", 9:"September", 10:"October", 11:"November", \
|
||||
12:"December"}
|
||||
def uid2openobjectid(cr, uidval, oomodel):
|
||||
__rege = re.compile(r'OpenERP-([\w|\.]+)_([0-9]+)@(\w+)$')
|
||||
wematch = __rege.match(uidval.encode('utf8'))
|
||||
if not wematch:
|
||||
# raise osv.except_osv('Warning!!', "Cannot locate UID in %s" % val['id'])
|
||||
return False
|
||||
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('.', '_'))
|
||||
ids = map(lambda x: str(x[0]), cr.fetchall())
|
||||
if id in ids:
|
||||
return id
|
||||
return False
|
||||
|
||||
|
||||
class crm_caldav_attendee(osv.osv):
|
||||
_name = 'crm.caldav.attendee'
|
||||
|
||||
@@ -187,7 +187,7 @@ class crm_case(osv.osv):
|
||||
return caendar_val
|
||||
|
||||
def import_cal(self, cr, uid, ids, data, context={}):
|
||||
file_content = base64.decodestring(data['form']['file_path'])
|
||||
file_content = base64.decodestring(data)
|
||||
event_obj = self.pool.get('caldav.event')
|
||||
event_obj.__attribute__.update(self.__attribute__)
|
||||
|
||||
@@ -203,9 +203,13 @@ class crm_case(osv.osv):
|
||||
# TODO: Select proper section
|
||||
section_id = self.pool.get('crm.case.section').search(cr, uid, [])[0]
|
||||
val.update({'section_id' : section_id})
|
||||
is_exists = common.uid2openobjectid(cr, val['id'], self._name )
|
||||
val.pop('id')
|
||||
val.pop('create_date')
|
||||
case_id = self.create(cr, uid, val)
|
||||
if is_exists:
|
||||
self.write(cr, uid, [is_exists], val)
|
||||
else:
|
||||
case_id = self.create(cr, uid, val)
|
||||
return {'count': len(vals)}
|
||||
|
||||
def search(self, cr, uid, args, offset=0, limit=None, order=None,
|
||||
|
||||
@@ -53,7 +53,7 @@ class crm_cal_import_wizard(wizard.interface):
|
||||
|
||||
def _process_imp_ics(self, cr, uid, data, context=None):
|
||||
case_obj = pooler.get_pool(cr.dbname).get('crm.case')
|
||||
vals = case_obj.import_cal(cr, uid, data['ids'], data, context)
|
||||
vals = case_obj.import_cal(cr, uid, data['ids'], data['form']['file_path'], context)
|
||||
global cnt
|
||||
cnt = 0
|
||||
if vals:
|
||||
|
||||
@@ -99,7 +99,7 @@ class project_task(osv.osv):
|
||||
}
|
||||
|
||||
def import_cal(self, cr, uid, ids, data, context={}):
|
||||
file_content = base64.decodestring(data['form']['file_path'])
|
||||
file_content = base64.decodestring(data)
|
||||
todo_obj = self.pool.get('caldav.todo')
|
||||
todo_obj.__attribute__.update(self.__attribute__)
|
||||
|
||||
@@ -125,8 +125,13 @@ class project_task(osv.osv):
|
||||
# Converts timedelta into Project time unit
|
||||
val['planned_hours'] = (val['planned_hours'].seconds/float(86400) + \
|
||||
val['planned_hours'].days) * obj_tm.factor
|
||||
|
||||
is_exists = common.uid2openobjectid(cr, val['id'], self._name )
|
||||
val.pop('id')
|
||||
task_id = self.create(cr, uid, val)
|
||||
if is_exists:
|
||||
self.write(cr, uid, [is_exists], val)
|
||||
else:
|
||||
case_id = self.create(cr, uid, val)
|
||||
return {'count': len(vals)}
|
||||
|
||||
def export_cal(self, cr, uid, ids, context={}):
|
||||
|
||||
@@ -53,7 +53,7 @@ class project_cal_imp_wizard(wizard.interface):
|
||||
|
||||
def _process_imp_ics(self, cr, uid, data, context=None):
|
||||
task_obj = pooler.get_pool(cr.dbname).get('project.task')
|
||||
vals = task_obj.import_cal(cr, uid, data['ids'], data, context)
|
||||
vals = task_obj.import_cal(cr, uid, data['ids'], data['form']['file_path'], context)
|
||||
global cnt
|
||||
cnt = 0
|
||||
if vals:
|
||||
|
||||
Reference in New Issue
Block a user