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)
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'):
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 = []
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
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
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')