summaryrefslogtreecommitdiff
path: root/addons/import_google/wizard/import_google_data.py
diff options
context:
space:
mode:
authorAmit Patel (OpenERP) <apa@tinyerp.com>2012-06-06 16:40:01 +0530
committerAmit Patel (OpenERP) <apa@tinyerp.com>2012-06-06 16:40:01 +0530
commit6573efdee167bb1b3057735739554c36aa2a2e88 (patch)
tree6ce4fee33f605b43fd885b490e9a0bba93fe1562 /addons/import_google/wizard/import_google_data.py
parent29c3da5730d7d847da39cae719b8d1f2f14602d2 (diff)
parent21bfdca845a71c1560432bec26d2c41801aabbf5 (diff)
[IMP]:import_google
bzr revid: apa@tinyerp.com-20120606111001-q1ob82nn33sjwxj7
Diffstat (limited to 'addons/import_google/wizard/import_google_data.py')
-rw-r--r--addons/import_google/wizard/import_google_data.py31
1 files changed, 18 insertions, 13 deletions
diff --git a/addons/import_google/wizard/import_google_data.py b/addons/import_google/wizard/import_google_data.py
index 4e16c039742..9affc13899e 100644
--- a/addons/import_google/wizard/import_google_data.py
+++ b/addons/import_google/wizard/import_google_data.py
@@ -65,21 +65,26 @@ class synchronize_google(osv.osv_memory):
_name = 'synchronize.google.import'
def _get_group(self, cr, uid, context=None):
- user_obj = self.pool.get('res.users').browse(cr, uid, uid)
- google=self.pool.get('google.login')
- if not user_obj.gmail_user or not user_obj.gmail_password:
- raise osv.except_osv(_('Warning !'), _("No Google Username or password Defined for user.\nPlease define in user view"))
- gd_client = google.google_login(user_obj.gmail_user,user_obj.gmail_password,type='group')
- if not gd_client:
- return [('failed', 'Connection to google fail')]
+ # all the selection field which have method are called at load time. why ?
+
res = []
- query = gdata.contacts.service.GroupsQuery(feed='/m8/feeds/groups/default/full')
- if gd_client:
- groups = gd_client.GetFeed(query.ToUri())
- for grp in groups.entry:
- res.append((grp.id.text, grp.title.text))
- res.append(('all','All Groups'))
+ if context:
+ user_obj = self.pool.get('res.users').browse(cr, uid, uid,context=context)
+ google=self.pool.get('google.login')
+ if not user_obj.gmail_user or not user_obj.gmail_password:
+ raise osv.except_osv(_('Warning !'), _("No Google Username or password Defined for user.\nPlease define in user view"))
+ gd_client = google.google_login(user_obj.gmail_user,user_obj.gmail_password,type='group')
+ if not gd_client:
+ return [('failed', 'Connection to google fail')]
+
+ res = []
+ query = gdata.contacts.service.GroupsQuery(feed='/m8/feeds/groups/default/full')
+ if gd_client:
+ groups = gd_client.GetFeed(query.ToUri())
+ for grp in groups.entry:
+ res.append((grp.id.text, grp.title.text))
+ res.append(('all','All Groups'))
return res
def _get_calendars(self, cr, uid, context=None):