[ADD]: Images: caldav, crm_caldav, document_webdav, project_caldav
[odoo/odoo.git] / addons / caldav / calendar.py
index 5a18fe8..a70a31b 100644 (file)
@@ -147,7 +147,8 @@ def get_attribute_mapping(cr, uid, calname, context=None):
         @param uid: the current user’s ID for security checks,
         @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')
@@ -158,7 +159,7 @@ def get_attribute_mapping(cr, uid, calname, context=None):
     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
@@ -228,7 +229,6 @@ def map_data(cr, uid, obj, context=None):
                     id = modobj.create(cr, uid, map_val, context=context)
                 vals[field] = id
                 continue
-            
             if field_type == 'timedelta':
                 if map_val:
                     vals[field] = (map_val.seconds/float(86400) + map_val.days)
@@ -484,7 +484,7 @@ class CalDAV(object):
             @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'))
@@ -594,8 +594,8 @@ class Calendar(CalDAV, osv.osv):
                                     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."),
@@ -606,7 +606,7 @@ class Calendar(CalDAV, osv.osv):
     }
 
     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 = []
@@ -636,7 +636,7 @@ class Calendar(CalDAV, osv.osv):
         
 
     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 = []
@@ -666,12 +666,12 @@ class Calendar(CalDAV, osv.osv):
             @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
@@ -698,7 +698,7 @@ class Calendar(CalDAV, osv.osv):
             @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
@@ -833,6 +833,7 @@ class basic_calendar_fields(osv.osv):
 
     _name = 'basic.calendar.fields'
     _description = 'Calendar fields'
+    _order = 'name'
 
     _columns = {
         'field_id': fields.many2one('ir.model.fields', 'OpenObject Field'),
@@ -901,6 +902,7 @@ class basic_calendar_fields(osv.osv):
             @param vals: Get Values
             @param context: A standard dictionary for contextual values
         """
+
         if not vals:
             return
         for id in ids:
@@ -1080,7 +1082,7 @@ class Timezone(CalDAV, osv.osv_memory):
             @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})
@@ -1139,8 +1141,6 @@ class Alarm(CalDAV, osv.osv_memory):
             @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, [])
@@ -1174,7 +1174,8 @@ class Alarm(CalDAV, osv.osv_memory):
             @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)
@@ -1241,7 +1242,8 @@ class Attendee(CalDAV, osv.osv_memory):
             @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)
@@ -1265,7 +1267,7 @@ class Attendee(CalDAV, osv.osv_memory):
             @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()
@@ -1293,5 +1295,4 @@ class Attendee(CalDAV, osv.osv_memory):
 
 Attendee()
 
-
 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: