[FIX] Calendar: resolve error to create task from Calendars clients
bzr revid: hmo@tinyerp.com-20100713114629-pmss2fdfjbu0gchi
This commit is contained in:
parent
0c3569c69f
commit
1263dd94ae
|
@ -228,7 +228,7 @@ class CalDAV(object):
|
|||
|
||||
att_data = []
|
||||
for cal_data in child.getChildren():
|
||||
if cal_data.name.lower() == 'organizer':
|
||||
if cal_data.name.lower() == 'organizer':
|
||||
self.ical_set(cal_data.name.lower(), {'name':cal_data.params['CN']}, 'value')
|
||||
if cal_data.name.lower() == 'attendee':
|
||||
ctx = context.copy()
|
||||
|
@ -268,7 +268,7 @@ class CalDAV(object):
|
|||
if not datas:
|
||||
return
|
||||
timezones = []
|
||||
for data in datas:
|
||||
for data in datas:
|
||||
tzval = None
|
||||
vevent = ical.add(name)
|
||||
for field in self.__attribute__.keys():
|
||||
|
@ -423,7 +423,7 @@ class CalDAV(object):
|
|||
return res
|
||||
|
||||
class Calendar(CalDAV, osv.osv):
|
||||
_name = 'basic.calendar'
|
||||
_name = 'basic.calendar'
|
||||
_calname = 'calendar'
|
||||
|
||||
__attribute__ = {
|
||||
|
@ -440,13 +440,13 @@ class Calendar(CalDAV, osv.osv):
|
|||
'vtimezone': None, # Use: O-n, Type: Collection of Timezone class
|
||||
}
|
||||
_columns = {
|
||||
'name': fields.char("Name", size=64),
|
||||
'name': fields.char("Name", size=64),
|
||||
'user_id': fields.many2one('res.users', 'Owner'),
|
||||
'collection_id': fields.many2one('document.directory', 'Collection', \
|
||||
required=True),
|
||||
'type': fields.selection([('vevent', 'Event'), ('vtodo', 'TODO')], \
|
||||
string="Type", size=64),
|
||||
'line_ids': fields.one2many('basic.calendar.lines', 'calendar_id', 'Calendar Lines'),
|
||||
'line_ids': fields.one2many('basic.calendar.lines', 'calendar_id', 'Calendar Lines'),
|
||||
'create_date': fields.datetime('Created Date'),
|
||||
'write_date': fields.datetime('Modifided Date'),
|
||||
}
|
||||
|
@ -457,8 +457,8 @@ class Calendar(CalDAV, osv.osv):
|
|||
if not domain:
|
||||
domain = []
|
||||
res = []
|
||||
ctx_res_id = context.get('res_id', None)
|
||||
ctx_model = context.get('model', None)
|
||||
ctx_res_id = context.get('res_id', None)
|
||||
ctx_model = context.get('model', None)
|
||||
for cal in self.browse(cr, uid, ids):
|
||||
for line in cal.line_ids:
|
||||
if ctx_model and ctx_model != line.object_id.model:
|
||||
|
@ -467,13 +467,13 @@ class Calendar(CalDAV, osv.osv):
|
|||
continue
|
||||
line_domain = eval(line.domain)
|
||||
line_domain += domain
|
||||
if ctx_res_id:
|
||||
if ctx_res_id:
|
||||
line_domain += [('id','=',ctx_res_id)]
|
||||
mod_obj = self.pool.get(line.object_id.model)
|
||||
data_ids = mod_obj.search(cr, uid, line_domain, context=context)
|
||||
data_ids = mod_obj.search(cr, uid, line_domain, context=context)
|
||||
for data in mod_obj.browse(cr, uid, data_ids, context):
|
||||
ctx = parent and parent.context or None
|
||||
node = res_node_calendar('%s' %data.id, parent, ctx, data, line.object_id.model, data.id)
|
||||
node = res_node_calendar('%s' %data.id, parent, ctx, data, line.object_id.model, data.id)
|
||||
res.append(node)
|
||||
return res
|
||||
|
||||
|
@ -487,8 +487,8 @@ class Calendar(CalDAV, osv.osv):
|
|||
"""
|
||||
if not context:
|
||||
context = {}
|
||||
ctx_model = context.get('model', None)
|
||||
ctx_res_id = context.get('res_id', None)
|
||||
ctx_model = context.get('model', None)
|
||||
ctx_res_id = context.get('res_id', None)
|
||||
ical = vobject.iCalendar()
|
||||
for cal in self.browse(cr, uid, ids):
|
||||
for line in cal.line_ids:
|
||||
|
@ -497,7 +497,7 @@ class Calendar(CalDAV, osv.osv):
|
|||
if line.name in ('valarm', 'attendee'):
|
||||
continue
|
||||
domain = eval(line.domain)
|
||||
if ctx_res_id:
|
||||
if ctx_res_id:
|
||||
domain += [('id','=',ctx_res_id)]
|
||||
mod_obj = self.pool.get(line.object_id.model)
|
||||
data_ids = mod_obj.search(cr, uid, domain, context=context)
|
||||
|
@ -505,7 +505,7 @@ class Calendar(CalDAV, osv.osv):
|
|||
context.update({'model': line.object_id.model,
|
||||
'calendar_id': cal.id
|
||||
})
|
||||
self.__attribute__ = get_attribute_mapping(cr, uid, line.name, context)
|
||||
self.__attribute__ = get_attribute_mapping(cr, uid, line.name, context)
|
||||
self.create_ics(cr, uid, datas, line.name, ical, context=context)
|
||||
return ical.serialize()
|
||||
|
||||
|
@ -520,16 +520,18 @@ class Calendar(CalDAV, osv.osv):
|
|||
|
||||
if not context:
|
||||
context = {}
|
||||
vals = []
|
||||
vals = []
|
||||
ical_data = base64.decodestring(content)
|
||||
parsedCal = vobject.readOne(ical_data)
|
||||
if not data_id:
|
||||
data_id = self.search(cr, uid, [])[0]
|
||||
data_id = self.search(cr, uid, [])[0]
|
||||
cal = self.browse(cr, uid, data_id, context=context)
|
||||
cal_children = {}
|
||||
count = 0
|
||||
for line in cal.line_ids:
|
||||
cal_children[line.name] = line.object_id.model
|
||||
objs = []
|
||||
checked = True
|
||||
for child in parsedCal.getChildren():
|
||||
if child.name.lower() in cal_children:
|
||||
context.update({'model': cal_children[child.name.lower()],
|
||||
|
@ -538,10 +540,13 @@ class Calendar(CalDAV, osv.osv):
|
|||
self.__attribute__ = get_attribute_mapping(cr, uid, child.name.lower(), context=context)
|
||||
val = self.parse_ics(cr, uid, child, cal_children=cal_children, context=context)
|
||||
vals.append(val)
|
||||
obj = self.pool.get(cal_children[child.name.lower()])
|
||||
if hasattr(obj, 'check_import'):
|
||||
obj.check_import(cr, uid, vals, context=context)
|
||||
else:
|
||||
objs.append(cal_children[child.name.lower()])
|
||||
for obj_name in list(set(objs)):
|
||||
obj = self.pool.get(obj_name)
|
||||
if hasattr(obj, 'check_import'):
|
||||
obj.check_import(cr, uid, vals, context=context)
|
||||
checked = True
|
||||
if not checked:
|
||||
self.check_import(cr, uid, vals, context=context)
|
||||
return {}
|
||||
Calendar()
|
||||
|
|
Loading…
Reference in New Issue