res[attr] = {}
res[attr]['field'] = field.field_id.name
res[attr]['type'] = field.field_id.ttype
+ if field.fn == 'datetime_utc':
+ res[attr]['type'] = 'utc'
if field.fn == 'hours':
res[attr]['type'] = "timedelta"
if res[attr]['type'] in ('one2many', 'many2many', 'many2one'):
@param name: Get Attribute Name
@param type: Get Attribute Type
"""
-
if self.__attribute__.get(name):
val = self.__attribute__.get(name).get(type, None)
valtype = self.__attribute__.get(name).get('type', None)
@param self: The object pointer,
@param type: Get Attribute Type
"""
-
for name in self.__attribute__:
if self.__attribute__[name]:
self.__attribute__[name][type] = None
dtfield.value = self.format_date_tz(parser.parse(data[map_field]), tzval.title())
else:
dtfield.value = parser.parse(data[map_field])
+
+ elif map_type == 'utc'and data[map_field]:
+ if tzval:
+ local = pytz.timezone (tzval.title())
+ naive = datetime.strptime (data[map_field], "%Y-%m-%d %H:%M:%S")
+ local_dt = naive.replace (tzinfo = local)
+ utc_dt = local_dt.astimezone (pytz.utc)
+ vevent.add(field).value = utc_dt
+ else:
+ utc_timezone = pytz.timezone ('UTC')
+ naive = datetime.strptime (data[map_field], "%Y-%m-%d %H:%M:%S")
+ local_dt = naive.replace (tzinfo = utc_timezone)
+ utc_dt = local_dt.astimezone (pytz.utc)
+ vevent.add(field).value = utc_dt
+
elif map_type == "timedelta":
vevent.add(field).value = timedelta(hours=data[map_field])
elif map_type == "many2one":
string="Type", size=64),
'line_ids': fields.one2many('basic.calendar.lines', 'calendar_id', 'Calendar Lines'),
'create_date': fields.datetime('Created Date', readonly=True),
- 'write_date': fields.datetime('Modifided Date', readonly=True),
- 'description': fields.text("description"),
+ 'write_date': fields.datetime('Write Date', readonly=True),
+ 'description': fields.text("Description"),
'calendar_color': fields.char('Color', size=20, help="For supporting clients, the color of the calendar entries"),
'calendar_order': fields.integer('Order', help="For supporting clients, the order of this folder among the calendars"),
'has_webcal': fields.boolean('WebCal', required=True, help="Also export a <name>.ics entry next to the calendar folder, with WebCal content."),
_name = 'basic.calendar.fields'
_description = 'Calendar fields'
+ _order = 'name'
_columns = {
'field_id': fields.many2one('ir.model.fields', 'OpenObject Field'),
'fn': fields.selection([('field', 'Use the field'),
('const', 'Expression as constant'),
('hours', 'Interval in hours'),
+ ('datetime_utc', 'Datetime In UTC'),
], 'Function'),
'mapping': fields.text('Mapping'),
}
_defaults = {
- 'fn': lambda *a: 'field',
+ 'fn': 'field',
}
_sql_constraints = [
self.__attribute__ = get_attribute_mapping(cr, uid, self._calname, ctx)
for child in ical_data.getChildren():
if child.name.lower() == 'trigger':
- seconds = child.value.seconds
- days = child.value.days
- diff = (days * 86400) + seconds
- interval = 'days'
- related = 'before'
+ if isinstance(child.value, timedelta):
+ seconds = child.value.seconds
+ days = child.value.days
+ diff = (days * 86400) + seconds
+ interval = 'days'
+ related = 'before'
+ elif isinstance(child.value, datetime):
+ # TODO
+ # remember, spec says this datetime is in UTC
+ raise NotImplementedError("we cannot parse absolute triggers")
if not seconds:
duration = abs(days)
related = days > 0 and 'after' or 'before'