[FIX] calendar: invalidate cache to avoid (pre)fetching invalid virtual IDs
authorXavier Morel <xmo@openerp.com>
Mon, 14 Jul 2014 13:41:40 +0000 (15:41 +0200)
committerXavier Morel <xmo@openerp.com>
Mon, 14 Jul 2014 13:41:40 +0000 (15:41 +0200)
Because the new API basically browses everything, the virtual IDs used by
calendar.event are added to the cache and prefetching tries to get them from
the database resulting in conversion errors. These ids have to be forcibly
evicted to avoid the error.

addons/calendar/calendar.py

index a77eb5e..920a05c 100644 (file)
@@ -1567,6 +1567,12 @@ class calendar_event(osv.Model):
             select = [ids]
         else:
             select = ids
+
+        # FIXME: find a better way to not push virtual ids in the cache
+        # (leading to their prefetching and ultimately a type error when
+        # postgres tries to convert '14-3489274297' to an integer)
+        self.invalidate_cache(cr, uid, context=context)
+
         select = map(lambda x: (x, calendar_id2real_id(x)), select)
         result = []
         real_data = super(calendar_event, self).read(cr, uid, [real_id for calendar_id, real_id in select], fields=fields2, context=context, load=load)