+ context_novirtual = self.get_context_no_virtual(context)
+
+ if lastSync:
+ try:
+ all_event_from_google = self.get_event_synchro_dict(cr, uid, lastSync=lastSync, context=context)
+ except urllib2.HTTPError, e:
+ if e.code == 410: # GONE, Google is lost.
+ # we need to force the rollback from this cursor, because it locks my res_users but I need to write in this tuple before to raise.
+ cr.rollback()
+ registry = openerp.modules.registry.RegistryManager.get(request.session.db)
+ with registry.cursor() as cur:
+ self.pool['res.users'].write(cur, uid, [uid], {'google_calendar_last_sync_date': False}, context=context)
+ error_key = simplejson.loads(e.read())
+ error_key = error_key.get('error', {}).get('message', 'nc')
+ error_msg = "Google are lost... the next synchro will be a full synchro. \n\n %s" % error_key
+ raise self.pool.get('res.config.settings').get_config_warning(cr, _(error_msg), context=context)
+
+ my_google_att_ids = att_obj.search(cr, uid, [
+ ('partner_id', '=', myPartnerID),
+ ('google_internal_event_id', 'in', all_event_from_google.keys())
+ ], context=context_novirtual)
+
+ my_openerp_att_ids = att_obj.search(cr, uid, [
+ ('partner_id', '=', myPartnerID),
+ ('event_id.oe_update_date', '>', lastSync and lastSync.strftime(DEFAULT_SERVER_DATETIME_FORMAT) or self.get_minTime(cr, uid, context).strftime(DEFAULT_SERVER_DATETIME_FORMAT)),
+ ('google_internal_event_id', '!=', False),
+ ], context=context_novirtual)
+
+ my_openerp_googleinternal_ids = att_obj.read(cr, uid, my_openerp_att_ids, ['google_internal_event_id', 'event_id'], context=context_novirtual)
+
+ if self.get_print_log(cr, uid, context=context):
+ _logger.info("Calendar Synchro - \n\nUPDATE IN GOOGLE\n%s\n\nRETRIEVE FROM OE\n%s\n\nUPDATE IN OE\n%s\n\nRETRIEVE FROM GG\n%s\n\n" % (all_event_from_google, my_google_att_ids, my_openerp_att_ids, my_openerp_googleinternal_ids))
+
+ for giid in my_openerp_googleinternal_ids:
+ active = True # if not sure, we request google
+ if giid.get('event_id'):
+ active = calendar_event.browse(cr, uid, int(giid.get('event_id')[0]), context=context_novirtual).active
+
+ if giid.get('google_internal_event_id') and not all_event_from_google.get(giid.get('google_internal_event_id')) and active:
+ one_event = self.get_one_event_synchro(cr, uid, giid.get('google_internal_event_id'), context=context)
+ if one_event:
+ all_event_from_google[one_event['id']] = one_event
+
+ my_att_ids = list(set(my_google_att_ids + my_openerp_att_ids))