@param calname: Get Calendar name
@param context: A standard dictionary for contextual values """
- if not context:
+ if context is None:
context = {}
pool = pooler.get_pool(cr.dbname)
field_obj = pool.get('basic.calendar.fields')
type_id = type_obj.search(cr, uid, domain)
fids = field_obj.search(cr, uid, [('type_id', '=', type_id[0])])
res = {}
- for field in field_obj.browse(cr, uid, fids):
+ for field in field_obj.browse(cr, uid, fids, context=context):
attr = field.name.name
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":
@param vals: Get Values
@param context: A standard dictionary for contextual values
"""
- if not context:
+ if context is None:
context = {}
ids = []
model_obj = self.pool.get(context.get('model'))
}
def get_calendar_objects(self, cr, uid, ids, parent=None, domain=None, context=None):
- if not context:
+ if context is None:
context = {}
if not domain:
domain = []
def get_cal_max_modified(self, cr, uid, ids, parent=None, domain=None, context=None):
- if not context:
+ if context is None:
context = {}
if not domain:
domain = []
@param vobj: the type of object to export
@return the ical data.
"""
- if not context:
+ if context is None:
context = {}
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 cal in self.browse(cr, uid, ids, context=context):
for line in cal.line_ids:
if ctx_model and ctx_model != line.object_id.model:
continue
@param data_id: Get Data’s ID or False
@param context: A standard dictionary for contextual values
"""
- if not context:
+ if context is None:
context = {}
vals = []
ical_data = content
'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'),
}
@param model: Get Model's name
@param context: A standard dictionary for contextual values
"""
- if not context:
+ if context is None:
context = {}
ctx = context.copy()
ctx.update({'model': model})
@param alarm_id: Get Alarm's Id
@param context: A standard dictionary for contextual values
"""
- if not context:
- context = {}
valarm = vevent.add('valarm')
alarm_object = self.pool.get(model)
alarm_data = alarm_object.read(cr, uid, alarm_id, [])
@param ical_data: Get calendar's Data
@param context: A standard dictionary for contextual values
"""
-
+ if context is None:
+ context = {}
ctx = context.copy()
ctx.update({'model': context.get('model', None)})
self.__attribute__ = get_attribute_mapping(cr, uid, self._calname, ctx)
@param ical_data: Get calendar's Data
@param context: A standard dictionary for contextual values
"""
-
+ if context is None:
+ context = {}
ctx = context.copy()
ctx.update({'model': context.get('model', None)})
self.__attribute__ = get_attribute_mapping(cr, uid, self._calname, ctx)
@param attendee_ids: Get Attendee's Id
@param context: A standard dictionary for contextual values
"""
- if not context:
+ if context is None:
context = {}
attendee_object = self.pool.get(model)
ctx = context.copy()