From 332b8df1fba8160c1561603b98e13af92abb9c71 Mon Sep 17 00:00:00 2001 From: jke-openerp Date: Fri, 13 Dec 2013 11:35:17 +0100 Subject: [PATCH] [REF] Cleaning old code, remove commented code, ... bzr revid: jke@openerp.com-20131213103517-ynzu2ti596dh3zm4 --- addons/google_calendar/google_calendar.py | 414 +++--------------- addons/google_calendar/google_calendar.pyc | Bin 30582 -> 23611 bytes .../static/description/index.html | 14 +- 3 files changed, 57 insertions(+), 371 deletions(-) diff --git a/addons/google_calendar/google_calendar.py b/addons/google_calendar/google_calendar.py index 131c39c8040..ba862c163e7 100644 --- a/addons/google_calendar/google_calendar.py +++ b/addons/google_calendar/google_calendar.py @@ -40,14 +40,10 @@ from openerp.osv import osv class google_calendar(osv.osv): - _name = 'google.calendar' - STR_SERVICE = 'calendar' + _name = 'google.%s' % STR_SERVICE -################################# -## DISCUSS WITH GMAIL ## -################################# - + def generate_data(self, cr, uid, event, context=None): if event.allday: start_date = fields.datetime.context_timestamp(cr, uid, datetime.strptime(event.date, tools.DEFAULT_SERVER_DATETIME_FORMAT) , context=context).isoformat('T').split('T')[0] @@ -98,8 +94,7 @@ class google_calendar(osv.osv): data_json = simplejson.dumps(data) return gs_pool._do_request(cr, uid, url, data_json, headers, type='POST', context=context) - - + def delete_an_event(self, cr, uid,event_id, context=None): gs_pool = self.pool.get('google.service') @@ -107,11 +102,9 @@ class google_calendar(osv.osv): 'access_token' : self.get_token(cr,uid,context) } headers = {'Content-type': 'application/json', 'Accept': 'text/plain'} - url = "/calendar/v3/calendars/%s/events/%s" % ('primary',event_id) - - response = gs_pool._do_request(cr, uid, url, params, headers, type='DELETE', context=context) - return response + + return gs_pool._do_request(cr, uid, url, params, headers, type='DELETE', context=context) def get_event_dict(self,cr,uid,token=False,nextPageToken=False,context=None): if not token: @@ -122,30 +115,21 @@ class google_calendar(osv.osv): params = { 'fields': 'items,nextPageToken', 'access_token' : token, -# 'orderBy' : 'id', #Allow to create the main recurrence event, before instance of it ! +# 'orderBy' : 'id', #Allow to create the main recurrence event, before instance of it ! DOESNT WORK ACTUALLY ON API GMAIL } headers = {'Content-type': 'application/json', 'Accept': 'text/plain'} url = "/calendar/v3/calendars/%s/events" % 'primary' #?fields=%s&access_token=%s" % ('primary',urllib.quote('items,nextPageToken'), token) if nextPageToken: params['pageToken'] = nextPageToken - - + content = gs_pool._do_request(cr, uid, url, params, headers, type='GET', context=context) google_events_dict = {} - - print content['items'] - for google_event in content['items']: google_events_dict[google_event['id']] = google_event - #if google_event.get('updated',False): -# if withInstance: -# for instance in self.get_instance_event(cr,uid,event_id,context): -# google_events_dict[instance['id']] = instance -# else: - + if content.get('nextPageToken', False): google_events_dict.update(self.get_event_dict(cr,uid,token,content['nextPageToken'],context=context)) return google_events_dict @@ -153,20 +137,15 @@ class google_calendar(osv.osv): def update_to_google(self, cr, uid, oe_event, google_event, context): crm_meeting = self.pool['crm.meeting'] gs_pool = self.pool.get('google.service') - url = "/calendar/v3/calendars/%s/events/%s?fields=%s&access_token=%s" % ('primary', google_event['id'],'id,updated', self.get_token(cr,uid,context)) headers = {'Content-type': 'application/json', 'Accept': 'text/plain'} data = self.generate_data(cr,uid ,oe_event, context) data['sequence'] = google_event.get('sequence', 0) data_json = simplejson.dumps(data) - - + content = gs_pool._do_request(cr, uid, url, data_json, headers, type='PATCH', context=context) - - #except urllib2.HTTPError,e: - # error_message = json.loads(e.read()) - + update_date = datetime.strptime(content['updated'],"%Y-%m-%dT%H:%M:%S.%fz") crm_meeting.write(cr, uid, [oe_event.id], {'oe_update_date':update_date}) @@ -199,11 +178,7 @@ class google_calendar(osv.osv): data['sequence'] = self.get_sequence(cr, uid, instance_id, context) data_json = simplejson.dumps(data) - response = gs_pool._do_request(cr, uid, url, data_json, headers, type='PUT', context=context) - - #TODO, il http fail, no event, do DELETE ! ? - - return response + return gs_pool._do_request(cr, uid, url, data_json, headers, type='PUT', context=context) def update_from_google(self, cr, uid, event, single_event_dict, type, context): if context is None: @@ -268,9 +243,6 @@ class google_calendar(osv.osv): 'attendee_ids': attendee_record, 'partner_ids': list(set(partner_record)), -# 'date': date, -# 'date_deadline': date_deadline, -# 'allday': allday, 'name': single_event_dict.get('summary','Event'), 'description': single_event_dict.get('description',False), 'location':single_event_dict.get('location',False), @@ -286,11 +258,11 @@ class google_calendar(osv.osv): if type == "write": return crm_meeting.write(cr, uid, event['id'], result, context=context) elif type == "copy": - #result['write_type'] = "copy" result['recurrence'] = True return crm_meeting.write(cr, uid, [event['id']], result, context=context) elif type == "create": return crm_meeting.create(cr, uid, result, context=context) + ################################# ## MANAGE SYNCHRO TO GMAIL ## ################################# @@ -324,7 +296,7 @@ class google_calendar(osv.osv): new_events_ids = crm_meeting.search(cr, uid,[('partner_ids', 'in', myPartnerID),('google_internal_event_id', '=', False),'|',('recurrent_id', '=', 0),('recurrent_id', '=', False)], context=context_norecurrent) for event in crm_meeting.browse(cr, uid, list(set(new_events_ids)), context): - #TODO rpelace it by a batch + #TODO replace it by a batch response = self.create_an_event(cr,uid,event,context=context) update_date = datetime.strptime(response['updated'],"%Y-%m-%dT%H:%M:%S.%fz") crm_meeting.write(cr, uid, event.id, {'google_internal_event_id': response['id'], 'oe_update_date':update_date}) @@ -374,9 +346,7 @@ class google_calendar(osv.osv): } - def update_events(self, cr, uid, context): - - + def update_events(self, cr, uid, context): crm_meeting = self.pool['crm.meeting'] user_obj = self.pool['res.users'] myPartnerID = user_obj.browse(cr,uid,uid,context=context).partner_id.id @@ -391,7 +361,6 @@ class google_calendar(osv.osv): # Select all events from OpenERP which have been already synchronized in gmail events_ids = crm_meeting.search(cr, uid,[('partner_ids', 'in', myPartnerID),('google_internal_event_id', '!=', False),('oe_update_date','!=', False)],order='google_internal_event_id',context=context_novirtual) - event_to_synchronize = {} for event in crm_meeting.browse(cr, uid, events_ids, context): base_event_id = event.google_internal_event_id.split('_')[0] @@ -432,18 +401,18 @@ class google_calendar(osv.osv): - print " $ Event IN Google " - print " $-----------------" - for ev in all_event_from_google: - print ' $ %s (%s) [%s]' % (all_event_from_google[ev].get('id'), all_event_from_google[ev].get('sequence'),all_event_from_google[ev].get('status')) - print " $-----------------" - print "" - print " $ Event IN OPENERP " - print " $------------------" - for event in crm_meeting.browse(cr, uid, events_ids, context): - print ' $ %s (%s) [%s]' % (event.google_internal_event_id, event.id,event.active) - print " $------------------" - +# print " $ Event IN Google " +# print " $-----------------" +# for ev in all_event_from_google: +# print ' $ %s (%s) [%s]' % (all_event_from_google[ev].get('id'), all_event_from_google[ev].get('sequence'),all_event_from_google[ev].get('status')) +# print " $-----------------" +# print "" +# print " $ Event IN OPENERP " +# print " $------------------" +# for event in crm_meeting.browse(cr, uid, events_ids, context): +# print ' $ %s (%s) [%s]' % (event.google_internal_event_id, event.id,event.active) +# print " $------------------" +# for base_event in event_to_synchronize: for current_event in event_to_synchronize[base_event]: @@ -492,8 +461,9 @@ class google_calendar(osv.osv): event['td_comment'] = "Both are already deleted" # New in openERP... Create on create_events of synchronize function elif event['OE_found'] and not event['GG_found']: - print "### Should never be here !!" - raise("error L 487") + #Has been deleted form gmail + event['td_action'] = 'DELETE' + event['td_comment'] = 'Removed from GOOGLE ?' elif event['GG_found'] and not event['OE_found']: event['td_source'] = 'GG' if not event['GG_status'] and not event['GG_isInstance']: @@ -513,24 +483,28 @@ class google_calendar(osv.osv): event['td_action'] = "CREATE" event['td_comment'] = 'New EVENT CREATE from GMAIL' - print " $ Event Merged " - print " $-----------------" +# print " $ Event Merged " +# print " $-----------------" for base_event in event_to_synchronize: print "Base Event : %s " % base_event event_to_synchronize[base_event] = sorted(event_to_synchronize[base_event].iteritems(),key=operator.itemgetter(0)) for current_event in event_to_synchronize[base_event]: + cr.commit() event = current_event[1] - print " Real Event %s (%s)" % (current_event[0],event['OE_event_id']) - print " Recurrence OE:%5s vs GG: %5s" % (event['OE_isRecurrence'],event['GG_isRecurrence']) - print " Instance OE:%5s vs GG: %5s" % (event['OE_isInstance'],event['GG_isInstance']) - print " Update OE: %10s " % (event['OE_update']) - print " Update GG: %10s " % (event['GG_update']) - print " Status OE:%5s vs GG: %5s" % (event['OE_status'],event['GG_status']) - print " Action %s" % (event['td_action']) - print " Source %s" % (event['td_source']) - print " comment %s" % (event['td_comment']) + ############# + ### DEBUG ### + ############# +# print " Real Event %s (%s)" % (current_event[0],event['OE_event_id']) +# print " Found OE:%5s vs GG: %5s" % (event['OE_found'],event['GG_found']) +# print " Recurrence OE:%5s vs GG: %5s" % (event['OE_isRecurrence'],event['GG_isRecurrence']) +# print " Instance OE:%5s vs GG: %5s" % (event['OE_isInstance'],event['GG_isInstance']) +# print " Update OE: %10s " % (event['OE_update']) +# print " Update GG: %10s " % (event['GG_update']) +# print " Status OE:%5s vs GG: %5s" % (event['OE_status'],event['GG_status']) +# print " Action %s" % (event['td_action']) +# print " Source %s" % (event['td_source']) +# print " comment %s" % (event['td_comment']) - actToDo = event['td_action'] actSrc = event['td_source'] if not actToDo: @@ -570,9 +544,6 @@ class google_calendar(osv.osv): if event_to_synchronize[base_event][0][1].get('OE_event_id'): parent_oe_id = event_to_synchronize[base_event][0][1].get('OE_event_id') crm_meeting.unlink(cr,uid,"%s-%s" % (parent_oe_id,new_google_event_id),unlink_level=1,context=context) - #else: - - #raise "Need to delete !" elif actToDo == 'DELETE': if actSrc == 'GG': @@ -580,145 +551,6 @@ class google_calendar(osv.osv): elif actSrc == 'OE': crm_meeting.unlink(cr,uid,event['OE_event_id'],unlink_level=0,context=context) return True -# -# 'oe_event_id' : False, -# 'oe_isRecurrence':False, -# 'oe_isInstance':False, -# 'oe_update':False, -# 'oe_status':False, -# -# #GOOGLE -# 'GG_isRecurrence':False, -# 'GG_isInstance':False, -# 'GG_update':False, -# 'GG_status':False, -# - - - #For each Event in MY CALENDAR (ALL has been already create in GMAIL in the past) - - # WARNING, NEED TO KEEP IDS SORTED !!! - # AS THAT, WE THREAT ALWAYS THE PARENT BEFORE THE RECURRENT - - for event_id in events_ids: - event = crm_meeting.browse(cr, uid, event_id, context) - cr.commit() - - # IF I HAVE BEEN DELETED FROM GOOGLE - if event.google_internal_event_id not in all_event_from_google: - print " __ !! OERP %s (%s) NOT IN google" % (event.google_internal_event_id,event.id) - - #If m the parent, we delete all all recurrence - if recurrency: - print "Master Event" - #If single i can delete - elif not event.recurrent_id or event.recurrent_id == 0: - print " __ !! Single Event (%s) has been delete in google" % (event.google_internal_event_id) - ids_deleted = crm_meeting.delete(cr,uid,event.id,context=context) - #ids should be alway single - assert len(ids_deleted)==1,"Warning, recurrent event (%s) deleted as a single event" % event.google_internal_event_id - print "IDS DELETED : ",ids_deleted - for id_deleted in [x for x in ids_deleted if x in events_ids]: - events_ids.remove(id_deleted) - #elif recurrency not event.recurrent_id or event.recurrent_id == 0: - - else: # I 'm a recurrence, removed from gmail - print "Unlink me simply ? Where i m passed ?" - raise "Unlink me simply ? Where i m passed ?" - - - else: - print " __ OERP %s (%s) IN google" % (event.google_internal_event_id,event.id) - - if event.active == False: - if all_event_from_google[event.google_internal_event_id].get('status')!='cancelled': - print " __ !! Event (%s) has been removed from OPENERP" % (event.google_internal_event_id) - #if len(crm_meeting.get_linked_ids(cr,uid,event.id,show_unactive=False,context=context)) == 1: #IF I'M ALONE - if crm_meeting.count_left_instance(cr,uid,event.id,context=context)==0: - print "COUNT LEFT INTANCE===" - print crm_meeting.count_left_instance(cr,uid,event.id,context=context) - temp = crm_meeting.get_linked_ids(cr,uid,event.id,show_unactive=False,context=context) - print "IDS LINKEND : IM ALONE = ",temp - print "@1___DELETE FROM GOOGLE THE EVENT AND DELETE FROM OPENERP : ",event.id - print "delete event from google : ",event.google_internal_event_id.split('_')[0] - print "delete event from openerp : ",event.id - - content = self.delete_an_event(cr,uid,event.google_internal_event_id.split('_')[0],context=context_novirtual) - ids_deleted = crm_meeting.delete(cr,uid,event.id,context=context_novirtual) - print "IDS DELETED : ",ids_deleted - for id_deleted in ids_deleted: - if id_deleted in events_ids: - events_ids.remove(id_deleted) - else : - print "@2___DELETE FROM GOOGLE THE EVENT AND HIDE FROM OPENERP : %s [%s]" % (event.id,event.google_internal_event_id) - content = self.delete_an_event(cr,uid,event.google_internal_event_id,context=context_novirtual) - crm_meeting.unlink(cr,uid,event.id,unlink_level=0,context=context) - - elif all_event_from_google[event.google_internal_event_id].get('status')=='cancelled': - print "@3___HAS BEEN REMOVED IN GOOGLE, HIDE IT IN OPENERP : ",event.id - crm_meeting.unlink(cr,uid,event.id,unlink_level=1,context=context) #Try to delete really in db if not recurrent - else: - print "@4___NEED UPDATE : %s " % (event.id) - self.check_and_sync(cr, uid, event, all_event_from_google[event.google_internal_event_id], context) - - if event.google_internal_event_id in all_new_event_from_google: - del all_new_event_from_google[event.google_internal_event_id] - - #FOR EACH EVENT CREATE IN GOOGLE, WE ADD THEM IN OERP - print " $ New Event IN Google " - print " $-----------------" - for ev in all_new_event_from_google: - print ' $ %s (%s) [%s]' % (all_new_event_from_google[ev].get('id'), all_new_event_from_google[ev].get('sequence'),all_new_event_from_google[ev].get('status')) - print " $-----------------" - print "" - - for new_google_event in all_new_event_from_google.values(): - if new_google_event.get('status','') == 'cancelled': - continue -# print "#### IN FOR #########" - elif new_google_event.get('recurringEventId',False): - - reccurent_event = crm_meeting.search(cr, uid, [('google_internal_event_id', '=', new_google_event['recurringEventId'])]) - - new_google_event_id = new_google_event['id'].split('_')[1] - if 'T' in new_google_event_id: - new_google_event_id = new_google_event_id.replace('T','')[:-1] - else: - new_google_event_id = new_google_event_id + "000000" - print "#############rec_event : ",reccurent_event - print "Google id : %s [%s]" % (new_google_event_id,new_google_event['id']) - for event_id in reccurent_event: - print "EVENT_ID = %s (%s)" % (event_id,event_id.split('-')[1]) - - if isinstance(event_id, str) and len(event_id.split('-'))>1 and event_id.split('-')[1] == new_google_event_id: - reccurnt_event_id = int(event_id.split('-')[0].strip()) - parent_event = crm_meeting.read(cr,uid, reccurnt_event_id, [], context) - parent_event['id'] = event_id - #recurrent update from google - - if new_google_event.get('status','') == 'cancelled': - print 'unlink -> cancelled in google' - crm_meeting.unlink(cr,uid,event_id,context) - else: - print "DO COPY?" - self.update_from_google(cr, uid, parent_event, new_google_event, "copy", context) - else: - print "ELSE" - elif new_google_event.get('recurrence',False) != False: #If was origin event from recurrent: - print "NEED TO CHECK IF AN INSTANCE ACTIVE..." - if True: #if a instance exist - self.update_from_google(cr, uid, False, new_google_event, "create", context) - # - else: - self.delete_an_event(cr, uid, new_google_event, context) - print ''#ELSE WE DELETE THE ORIGIN EVENT - else : - print "@and not recurring event" - #new event from google - self.update_from_google(cr, uid, False, new_google_event, "create", context) - # del google_events_dict[new_google_event['id']] - return True - def bind_recurring_events_to_google(self, cr, uid, context): crm_meeting = self.pool['crm.meeting'] @@ -743,9 +575,8 @@ class google_calendar(osv.osv): if new_google_internal_event_id: crm_meeting.write(cr, uid, [event.id], {'google_internal_event_id': new_google_internal_event_id}) - #Create new event calendar with exlude recuureent_id on RecurringEventID - #TODO WARNING, NEED TO CHECK THAT EVENT and ALl insatance NOT DELETE IN GMAIL BEFORE ! + #TODO WARNING, NEED TO CHECK THAT EVENT and ALL instance NOT DELETE IN GMAIL BEFORE ! self.update_recurrent_event_exclu(cr,uid,new_google_internal_event_id,source_record.google_internal_event_id,event,context=context) @@ -769,149 +600,6 @@ class google_calendar(osv.osv): content = gs_pool._do_request(cr, uid, url, params, headers, type='GET', context=context) return content.get('sequence',0) - - def update_events_ORI(self, cr, uid, context): - crm_meeting = self.pool['crm.meeting'] - user_obj = self.pool['res.users'] - myPartnerID = user_obj.browse(cr,uid,uid,context=context).partner_id.id - - context_novirtual = context.copy() - context_novirtual['virtual_id'] = False - - all_event_from_google = self.get_event_dict(cr,uid,context=context) - all_new_event_from_google = all_event_from_google.copy() - - events_ids = crm_meeting.search(cr, uid,[('partner_ids', 'in', myPartnerID),('google_internal_event_id', '!=', False),('oe_update_date','!=', False),'|',('active','=',False),('active','=',True)],order='google_internal_event_id',context=context_novirtual) #MORE ACTIVE = False - - print " $ Event IN Google " - print " $-----------------" - for ev in all_event_from_google: - print ' $ %s (%s) [%s]' % (all_event_from_google[ev].get('id'), all_event_from_google[ev].get('sequence'),all_event_from_google[ev].get('status')) - print " $-----------------" - print "" - print " $ Event IN OPENERP " - print " $------------------" - for event in crm_meeting.browse(cr, uid, events_ids, context): - print ' $ %s (%s) [%s]' % (event.google_internal_event_id, event.id,event.active) - print " $------------------" - - #For each Event in MY CALENDAR (ALL has been already create in GMAIL in the past) - - # WARNING, NEED TO KEEP IDS SORTED !!! - # AS THAT, WE THREAT ALWAYS THE PARENT BEFORE THE RECURRENT - - for event_id in events_ids: - event = crm_meeting.browse(cr, uid, event_id, context) - cr.commit() - - # IF I HAVE BEEN DELETED FROM GOOGLE - if event.google_internal_event_id not in all_event_from_google: - print " __ !! OERP %s (%s) NOT IN google" % (event.google_internal_event_id,event.id) - - #If m the parent, we delete all all recurrence - if not event.recurrent_id or event.recurrent_id == 0: - print " __ !! Master Event (%s) has been deleted has been delete in google" % (event.google_internal_event_id) - ids_deleted = crm_meeting.delete(cr,uid,event.id,context=context) - print "IDS DELETED : ",ids_deleted - for id_deleted in [x for x in ids_deleted if x in events_ids]: - #if id_deleted in events_ids: - events_ids.remove(id_deleted) - else: # I 'm and recurrence, removed from gmail - print "Unlink me simply ? Where i m passed ?" - raise "Unlink me simply ? Where i m passed ?" - - - else: - print " __ OERP %s (%s) IN google" % (event.google_internal_event_id,event.id) - - if event.active == False: - if all_event_from_google[event.google_internal_event_id].get('status')!='cancelled': - print " __ !! Event (%s) has been removed from OPENERP" % (event.google_internal_event_id) - #if len(crm_meeting.get_linked_ids(cr,uid,event.id,show_unactive=False,context=context)) == 1: #IF I'M ALONE - if crm_meeting.count_left_instance(cr,uid,event.id,context=context)==0: - print "COUNT LEFT INTANCE===" - print crm_meeting.count_left_instance(cr,uid,event.id,context=context) - temp = crm_meeting.get_linked_ids(cr,uid,event.id,show_unactive=False,context=context) - print "IDS LINKEND : IM ALONE = ",temp - print "@1___DELETE FROM GOOGLE THE EVENT AND DELETE FROM OPENERP : ",event.id - print "delete event from google : ",event.google_internal_event_id.split('_')[0] - print "delete event from openerp : ",event.id - - content = self.delete_an_event(cr,uid,event.google_internal_event_id.split('_')[0],context=context_novirtual) - ids_deleted = crm_meeting.delete(cr,uid,event.id,context=context_novirtual) - print "IDS DELETED : ",ids_deleted - for id_deleted in ids_deleted: - if id_deleted in events_ids: - events_ids.remove(id_deleted) - else : - print "@2___DELETE FROM GOOGLE THE EVENT AND HIDE FROM OPENERP : %s [%s]" % (event.id,event.google_internal_event_id) - content = self.delete_an_event(cr,uid,event.google_internal_event_id,context=context_novirtual) - crm_meeting.unlink(cr,uid,event.id,unlink_level=0,context=context) - - elif all_event_from_google[event.google_internal_event_id].get('status')=='cancelled': - print "@3___HAS BEEN REMOVED IN GOOGLE, HIDE IT IN OPENERP : ",event.id - crm_meeting.unlink(cr,uid,event.id,unlink_level=1,context=context) #Try to delete really in db if not recurrent - else: - print "@4___NEED UPDATE : %s " % (event.id) - self.check_and_sync(cr, uid, event, all_event_from_google[event.google_internal_event_id], context) - - if event.google_internal_event_id in all_new_event_from_google: - del all_new_event_from_google[event.google_internal_event_id] - - #FOR EACH EVENT CREATE IN GOOGLE, WE ADD THEM IN OERP - print " $ New Event IN Google " - print " $-----------------" - for ev in all_new_event_from_google: - print ' $ %s (%s) [%s]' % (all_new_event_from_google[ev].get('id'), all_new_event_from_google[ev].get('sequence'),all_new_event_from_google[ev].get('status')) - print " $-----------------" - print "" - - for new_google_event in all_new_event_from_google.values(): - if new_google_event.get('status','') == 'cancelled': - continue -# print "#### IN FOR #########" - elif new_google_event.get('recurringEventId',False): - - reccurent_event = crm_meeting.search(cr, uid, [('google_internal_event_id', '=', new_google_event['recurringEventId'])]) - - new_google_event_id = new_google_event['id'].split('_')[1] - if 'T' in new_google_event_id: - new_google_event_id = new_google_event_id.replace('T','')[:-1] - else: - new_google_event_id = new_google_event_id + "000000" - print "#############rec_event : ",reccurent_event - print "Google id : %s [%s]" % (new_google_event_id,new_google_event['id']) - for event_id in reccurent_event: - print "EVENT_ID = %s (%s)" % (event_id,event_id.split('-')[1]) - - if isinstance(event_id, str) and len(event_id.split('-'))>1 and event_id.split('-')[1] == new_google_event_id: - reccurnt_event_id = int(event_id.split('-')[0].strip()) - parent_event = crm_meeting.read(cr,uid, reccurnt_event_id, [], context) - parent_event['id'] = event_id - #recurrent update from google - - if new_google_event.get('status','') == 'cancelled': - print 'unlink -> cancelled in google' - crm_meeting.unlink(cr,uid,event_id,context) - else: - print "DO COPY?" - self.update_from_google(cr, uid, parent_event, new_google_event, "copy", context) - else: - print "ELSE" - elif new_google_event.get('recurrence',False) != False: #If was origin event from recurrent: - print "NEED TO CHECK IF AN INSTANCE ACTIVE..." - if True: #if a instance exist - self.update_from_google(cr, uid, False, new_google_event, "create", context) - # - else: - self.delete_an_event(cr, uid, new_google_event, context) - print ''#ELSE WE DELETE THE ORIGIN EVENT - else : - print "@and not recurring event" - #new event from google - self.update_from_google(cr, uid, False, new_google_event, "create", context) - # del google_events_dict[new_google_event['id']] - return True ################################# ## MANAGE CONNEXION TO GMAIL ## @@ -965,6 +653,8 @@ class google_calendar(osv.osv): vals['google_%s_token' % self.STR_SERVICE] = all_token.get('access_token') self.pool.get('res.users').write(cr,uid,uid,vals,context=context) + + class res_users(osv.osv): _inherit = 'res.users' @@ -973,13 +663,6 @@ class res_users(osv.osv): 'google_calendar_token': fields.char('User token'), 'google_calendar_token_validity': fields.datetime('Token Validity'), } - -# def get_cal_token_info(self, cr, uid, partner_id=False, context=None): -# if partner_id: -# user = self.pool.get('res.partner').browse(cr,uid,partner_id,context=context).user_id -# else: -# user = self.pool.get('res.users').browse(cr,uid,uid,context=context) -# return dict(authcode=user.google_cal_authcode, token=user.google_cal_token, validity=user.google_cal_token_validity,) class crm_meeting(osv.osv): @@ -1014,6 +697,7 @@ class crm_meeting(osv.osv): class calendar_attendee(osv.osv): _inherit = 'calendar.attendee' + def write(self, cr, uid, ids, vals, context=None): for id in ids: ref = vals.get('event_id',self.browse(cr,uid,id,context=context).event_id.id) diff --git a/addons/google_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c!qi(O1TY z%X4KTkvDueL`%UU-&QK@^e7~JxWzTp#fQK#MGMMB;lYR42?`(H;4VH40UqAq8T$sd z*H+3`anHN>Q0;l(za@LV+*faai=QJdU1-Eb1MysIj6F z%rz4uC!ZO!{$LJo6COFL|4s=H{dUmHz-SR4ViMqzXA_nD z_leN0?=Dc%{tzsAk5~{-(NI4CQpAm3V5ku7GW;hD8nEw<2tRUA=fQNQLAJWU&XyoI zUIv;aD}Om;XMT;8t^{)*hUM&!63m%&o4pI7`v5>^12caBsQds#XTC&>-8-yXj_RhR zvG)HF+fl)p^Z+sa9{!nsO}0?en4a=kr5(4 zCh{Ld-X!v$L|>)K0EjZ=kGe79NHXy zk0LNg6v?A211?gb0b<9~i z9^ySt=ePmyPFJ>82C8Z*9cOI((+wO#7QG=H$Mb|CtuTM#{CvEr_GcLE2$J49(pJx% zcJqlq1KKa?i+^I?qImUBY)2}c%M;VucXj8^#Loin(u5Z0&hbxZ|ExQ6Ctma!nBn~J zME}kX0-r@?Xf=}BYczJ2h}^4ky(VJFcr`nJoS4_XtuMAdGS91&Zep(I&cbM;lb#6B z^0!Z((|)QuYfm+XT~i^_=o~!tc=LKlze7PK02}}m?`Wa5UU9y7>WwJ*VhZY$m<-jp X^NZ89e2Wu(bW`v>_PJPXto45Z^y`)* diff --git a/addons/google_calendar/static/description/index.html b/addons/google_calendar/static/description/index.html index b4732c29c3c..745b825b309 100644 --- a/addons/google_calendar/static/description/index.html +++ b/addons/google_calendar/static/description/index.html @@ -31,9 +31,10 @@

In just one click you can create an event...
+ You can drag and drop your event if you want moved it to another timing.
+ You can shrink or extend the event if you need to change the start's hours or the duration of your meeting.

-
- + @@ -42,7 +43,8 @@

Create recurrent event

- You can also create recurrent events with only one event. + You can also create recurrent events with only one event.
+ You need to create an event each monday of the week ? With only one it's possible, you could specify the recurrence and if one of this event is moved, or deleted, it's not a problem, you can untie your event from the others recurrences.

@@ -60,8 +62,8 @@

- See in your calendar, the event from others peoples where your are attendees, but also their events by simply adding your favorites coworkers.
- Every coworker will have their own color in your calendar, and every attendee wil lhave their avatar in the event...
+ See in your calendar, the event from others peoples where your are attendee, but also their events by simply adding your favorites coworkers.
+ Every coworker will have their own color in your calendar, and every attendee will have their avatar in the event...

@@ -73,7 +75,7 @@

Get an email

- You will receive an email at creation of an event where you are attendee, but also when htis event is updated for some fields as date start, ... + You will receive an email at creation of an event where you are attendee, but also when this event is updated for some fields as date start, ...