[IMP]: base_calendar, caldav: Improvement and Fixed problems in import/export .ics

bzr revid: rpa@openerp.co.in-20100121101024-cr36ykm8z2aysxg7
This commit is contained in:
rpa (Open ERP) 2010-01-21 15:40:24 +05:30
parent c7608d1fd7
commit e2c0a6665a
3 changed files with 16 additions and 11 deletions

View File

@ -145,8 +145,6 @@ class CalDAV(object):
val = ','.join(map(lambda x: x.strftime('%Y-%m-%d %H:%M:%S'), val))
else:
val = val.strftime('%Y-%m-%d %H:%M:%S')
if valtype and valtype == 'integer' and val:
val = int(val)
return val
else:
return self.__attribute__.get(name, None)
@ -194,7 +192,7 @@ class CalDAV(object):
vevent = alarm_obj.export_ical(cr, uid, model, \
data[map_field][0], vevent, context=context)
elif data[map_field]:
if map_type == "text":
if map_type in ("char", "text"):
vevent.add(field).value = str(data[map_field])
elif map_type == 'datetime' and data[map_field]:
if field in ('exdate'):
@ -205,13 +203,19 @@ class CalDAV(object):
vevent.add(field).value = timedelta(hours=data[map_field])
elif map_type == "many2one":
vevent.add(field).value = [data.get(map_field)[1]]
if self.__attribute__.get(field).has_key('mapping'):
for key1, val1 in self.ical_get(field, 'mapping').items():
if val1 == data[map_field]:
vevent.add(field).value = key1
elif map_type in ("float", "integer"):
vevent.add(field).value = [data.get(map_field)]
elif map_type == "selection":
if not self.ical_get(field, 'mapping'):
vevent.add(field).value = (data[map_field]).upper()
else:
for key1, val1 in self.ical_get(field, 'mapping').items():
if val1 == data[map_field]:
vevent.add(field).value = key1
return ical
def import_ical(self, cr, uid, ical_data):
self.__attribute__ = get_attribute_mapping(cr, uid, self._name)
parsedCal = vobject.readOne(ical_data)
att_data = []
res = []

View File

@ -733,7 +733,7 @@ class calendar_todo(osv.osv):
obj_tm = self.pool.get('res.users').browse(cr, uid, uid, context).company_id.project_time_mode_id
if not val.has_key('planned_hours'):
# 'Computes duration' in days
start = datetime.strptime(val['date_start'], '%Y-%m-%d %H:%M:%S')
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
plan = (diff.seconds/float(86400) + diff.days) * obj_tm.factor
@ -759,7 +759,7 @@ class calendar_todo(osv.osv):
task.pop('planned_hours')
tasks.append(task)
todo_obj = self.pool.get('basic.calendar.todo')
ical = todo_obj.export_ical(cr, uid, tasks, {'model': 'project.task'})
ical = todo_obj.export_ical(cr, uid, tasks, context={'model': self._name})
calendar_val = ical.serialize()
calendar_val = calendar_val.replace('"', '').strip()
return calendar_val

View File

@ -51,13 +51,14 @@ class cal_event_export_wizard(wizard.interface):
model_obj = pooler.get_pool(cr.dbname).get(model)
calendar = model_obj.export_cal(cr, uid, data['ids'], context)
return {'file_path': base64.encodestring(calendar), \
'name': 'OpenERP Events.ics'}
'name': 'OpenERP %s.ics' % (model_obj._description)}
states = {
'init': {
'actions': [_process_export_ics],
'result': {'type': 'form', 'arch':form1, 'fields':form1_fields, \
'state': [('end', '_Cancel', 'gtk-cancel'), ('end', 'Ok', 'gtk-ok')]}},
'state': [('end', '_Cancel', 'gtk-cancel'), \
('end', 'Ok', 'gtk-ok')]}},
}
cal_event_export_wizard('caldav.event.export')