def initialize(self):
google = self.obj.pool.get('google.login')
self.external_id_field = 'Id'
- self.gclient=self.context.get('gd_client', False)
self.gd_client = google.google_login(self.context.get('user'),
self.context.get('password'),
- type = self.context.get('instance'))
+ self.context.get('instance'))
+
+ if self.context.get('instance') and self.context.get('instance') == 'contact':
+ self.contact = self.context.get('contact')
if self.context.get('instance') and self.context.get('instance') == 'calendar':
self.calendars = self.context.get('calendars')
def get_contact(self):
- contact=self.gclient
- gclient=self.context.get('client',False)
table = self.context.get('table')[0]
datas = []
- while contact:
- for entry in contact.entry:
-
+ if self.context.get('group_name'):
+ query = gdata.contacts.service.ContactsQuery()
+ query.group = self.context.get('group_name')
+ self.contact = self.gd_client.GetContactsFeed(query.ToUri())
+ else:
+ self.contact = self.gd_client.GetContactsFeed()
+ while self.contact:
+ for entry in self.contact.entry:
data = {}
data['id'] = entry.id.text
name = tools.ustr(entry.title.text)
if phone.rel == gdata.contacts.PHONE_WORK_FAX:
data['fax'] = phone.text
datas.append(data)
- next = contact.GetNextLink()
- contact = next and gclient.GetContactsFeed(next.href) or None
+ next = self.contact.GetNextLink()
+ self.contact = next and self.gd_client.GetContactsFeed(next.href) or None
return datas
def get_partner_address(self,val):
if not gd_client:
raise osv.except_osv(_('Error'), _("Please specify correct user and password !"))
if obj.group_name not in ['all']:
- query = gdata.contacts.service.ContactsQuery()
- query.group = obj.group_name
- contact = gd_client.GetContactsFeed(query.ToUri())
- else:
- contact = gd_client.GetContactsFeed()
+ context.update({ 'group_name': obj.group_name})
if obj.create_partner=='create_all':
tables.append('Contact')
else:
tables.append('Address')
- context.update({'gd_client':contact,
- 'client':gd_client,
+ context.update({'user': gmail_user,
+ 'password': gmail_pwd,
+ 'instance': 'contact',
'table':tables,
'customer':cust,
'supplier':sup})
imp = google_import(self, cr, uid,'import_google' , "synchronize_google", gmail_user, context)
imp.set_table_list(tables)
imp.start()
- return {}
+ #return {}
+ msg = " you're Contact import in background, a email will be send when the process is finished to %s"%(user_obj.gmail_user)
+ context.update({'message': msg})
+
+ obj_model = self.pool.get('ir.model.data')
+ model_data_ids = obj_model.search(cr,uid,[('model','=','ir.ui.view'),('name','=','view_google_import_message_form')])
+ resource_id = obj_model.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id']
+
+ return {
+ 'view_type': 'form',
+ 'view_mode': 'form',
+ 'res_model': 'google.import.message',
+ 'views': [(resource_id,'form')],
+ 'type': 'ir.actions.act_window',
+ 'target': 'new',
+ 'context': context,
+ }
synchronize_google()