From 2c6023b559af79d655efa1b45476f0b631cda6d8 Mon Sep 17 00:00:00 2001 From: "DBR (OpenERP)" Date: Mon, 13 Jun 2011 12:08:39 +0530 Subject: [REF]import_google: rename the file bzr revid: dbr@tinyerp.com-20110613063839-zy27ck9t21j6sjdh --- addons/import_google/wizard/import_google_data.py | 177 ++++++++++++++++++++++ 1 file changed, 177 insertions(+) create mode 100644 addons/import_google/wizard/import_google_data.py (limited to 'addons/import_google/wizard/import_google_data.py') diff --git a/addons/import_google/wizard/import_google_data.py b/addons/import_google/wizard/import_google_data.py new file mode 100644 index 00000000000..6c3bea47f21 --- /dev/null +++ b/addons/import_google/wizard/import_google_data.py @@ -0,0 +1,177 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## +import datetime + +try: + import gdata + import gdata.contacts.service + import gdata.contacts +except ImportError: + raise osv.except_osv(_('Google Contacts Import Error!'), _('Please install gdata-python-client from http://code.google.com/p/gdata-python-client/downloads/list')) +from osv import fields +from osv import osv +from tools.translate import _ +from import_google import google_import + + +class google_login_contact(osv.osv_memory): + _inherit = 'google.login' + _name = 'google.login' + + def _get_next_action(self, cr, uid, context=None): + data_obj = self.pool.get('ir.model.data') + data_id = data_obj._get_id(cr, uid, 'import_google', 'view_synchronize_google_contact_import_form') + view_id = False + if context.get('contact'): + data_id = data_obj._get_id(cr, uid, 'import_google', 'view_synchronize_google_contact_import_form') + if context.get('calendar'): + data_id = data_obj._get_id(cr, uid, 'import_google', 'view_synchronize_google_calendar_import_form') + if data_id: + view_id = data_obj.browse(cr, uid, data_id, context=context).res_id + value = { + 'name': _('Import google'), + 'view_type': 'form', + 'view_mode': 'form,tree', + 'res_model': 'synchronize.google.contact.import', + 'view_id': False, + 'context': context, + 'views': [(view_id, 'form')], + 'type': 'ir.actions.act_window', + 'target': 'new', + } + return value + +google_login_contact() + +class synchronize_google_contact(osv.osv_memory): + _name = 'synchronize.google.contact.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: + raise osv.except_osv(_('Error'), _("Authentication fail check the user and password !")) + + 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): + user_obj = self.pool.get('res.users').browse(cr, uid, uid) + google = self.pool.get('google.login') + res = [] + try: + gd_client = google.google_login(user_obj.gmail_user, user_obj.gmail_password, type='calendar') + calendars = gd_client.GetAllCalendarsFeed() + for cal in calendars.entry: + res.append((cal.id.text, cal.title.text)) + except Exception, e: + raise osv.except_osv('Error !', e.args[0].get('body')) + res.append(('all', 'All Calendars')) + return res + + _columns = { + 'create_partner': fields.selection([('create_all','Create partner for each contact'),('create_address','Import only address')],'Options'), + 'customer': fields.boolean('Customer', help="Check this box to set newly created partner as Customer."), + 'supplier': fields.boolean('Supplier', help="Check this box to set newly created partner as Supplier."), + 'group_name': fields.selection(_get_group, "Group Name", size=32,help="Choose which group to import, By default it takes all."), + 'calendar_name': fields.selection(_get_calendars, "Calendar Name", size=32), + } + + _defaults = { + 'create_partner': 'create_all', + 'group_name': 'all', + 'calendar_name': 'all', + } + + def import_contact(self, cr, uid, ids, context=None): + obj = self.browse(cr, uid, ids, context=context)[0] + cust = obj.customer + sup = obj.supplier + tables=[] + user_obj = self.pool.get('res.users').browse(cr, uid, uid) + + gmail_user = user_obj.gmail_user + gmail_pwd = user_obj.gmail_password + + google = self.pool.get('google.login') + gd_client = google.google_login(gmail_user, gmail_pwd, type='contact') + 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() + if obj.create_partner=='create_all': + tables.append('Contact') + else: + tables.append('Address') + + context.update({'gd_client':contact}) + context.update({'client':gd_client}) + context.update({'table':tables}) + context.update({'customer':cust}) + context.update({'supplier':sup}) + imp = google_import(self, cr, uid, 'google', "synchronize_google_contact", gmail_user, context) + imp.set_table_list(tables) + imp.start() + return {} + + def import_calendar_events(self, cr, uid, ids, context=None): + if context == None: + context = {} + if not ids: + return {'type': 'ir.actions.act_window_close'} + table = ['Events'] + user_obj = self.pool.get('res.users').browse(cr, uid, uid) + gmail_user = user_obj.gmail_user + gmail_pwd = user_obj.gmail_password + if not gmail_user or not gmail_pwd: + raise osv.except_osv(_('Error'), _("Invalid login detail !\n Specify Username/Password.")) + current_rec = self.browse(cr, uid, ids, context=context) + calendars = False + for rec in current_rec: + if rec.calendar_name != 'all': + calendars = [rec.calendar_name] + else: + calendars = map(lambda x: x[0], [cal for cal in self._get_calendars(cr, uid, context) if cal[0] != 'all']) + context.update({'user': gmail_user, + 'password': gmail_pwd, + 'calendars': calendars, + 'instance': 'calendar'}) + imp = google_import(self, cr, uid, 'import_google', "import_google_calendar", [gmail_user], context) + imp.set_table_list(table) + imp.start() + return {} + +synchronize_google_contact() + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: -- cgit v1.2.3 From 0e588677ed41d9a56994de5ca1b59a195176b45a Mon Sep 17 00:00:00 2001 From: "DBR (OpenERP)" Date: Mon, 13 Jun 2011 12:40:42 +0530 Subject: [ADD]import_google: Add two files bzr revid: dbr@tinyerp.com-20110613071042-b1zp3enejqip7z5p --- addons/import_google/wizard/import_google_data.py | 30 +++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) (limited to 'addons/import_google/wizard/import_google_data.py') diff --git a/addons/import_google/wizard/import_google_data.py b/addons/import_google/wizard/import_google_data.py index 6c3bea47f21..02244e7a0d6 100644 --- a/addons/import_google/wizard/import_google_data.py +++ b/addons/import_google/wizard/import_google_data.py @@ -143,7 +143,20 @@ class synchronize_google_contact(osv.osv_memory): imp = google_import(self, cr, uid, 'google', "synchronize_google_contact", gmail_user, context) imp.set_table_list(tables) imp.start() - return {} + return{} +# context.update({'message': "Data Imported Successffully from Google."}) +# model_pool = self.pool.get('ir.model.data') +# model_data_ids = model_pool.search(cr, uid, [('model', '=', 'ir.ui.view'), ('name', '=', 'google.import.message.form')]) +# resource_id = model_pool.read(cr, uid, model_data_ids, fields) +# 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, +# } def import_calendar_events(self, cr, uid, ids, context=None): if context == None: @@ -170,7 +183,20 @@ class synchronize_google_contact(osv.osv_memory): imp = google_import(self, cr, uid, 'import_google', "import_google_calendar", [gmail_user], context) imp.set_table_list(table) imp.start() - return {} + + context.update({'message': "Data Imported Successffully from Google."}) + model_pool = self.pool.get('ir.model.data') + model_data_ids = model_pool.search(cr, uid, [('model', '=', 'ir.ui.view'), ('name', '=', 'google.import.message.form')]) + resource_id = model_pool.read(cr, uid, model_data_ids, fields) + 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_contact() -- cgit v1.2.3 From 27c02a115e47b4c278b636d8a90d750f0644e88d Mon Sep 17 00:00:00 2001 From: "DBR (OpenERP)" Date: Mon, 13 Jun 2011 14:48:50 +0530 Subject: [IMP]import_google : Change in message wizard view bzr revid: dbr@tinyerp.com-20110613091850-lcakq2i19g4mm95e --- addons/import_google/wizard/import_google_data.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'addons/import_google/wizard/import_google_data.py') diff --git a/addons/import_google/wizard/import_google_data.py b/addons/import_google/wizard/import_google_data.py index 02244e7a0d6..813cdc1d3e7 100644 --- a/addons/import_google/wizard/import_google_data.py +++ b/addons/import_google/wizard/import_google_data.py @@ -111,11 +111,17 @@ class synchronize_google_contact(osv.osv_memory): } def import_contact(self, cr, uid, ids, context=None): + if context == None: + context = {} + if not ids: + return {'type': 'ir.actions.act_window_close'} obj = self.browse(cr, uid, ids, context=context)[0] cust = obj.customer sup = obj.supplier tables=[] user_obj = self.pool.get('res.users').browse(cr, uid, uid) + if not gmail_user or not gmail_pwd: + raise osv.except_osv(_('Error'), _("Invalid login detail !\n Specify Username/Password.")) gmail_user = user_obj.gmail_user gmail_pwd = user_obj.gmail_password @@ -135,11 +141,11 @@ class synchronize_google_contact(osv.osv_memory): else: tables.append('Address') - context.update({'gd_client':contact}) - context.update({'client':gd_client}) - context.update({'table':tables}) - context.update({'customer':cust}) - context.update({'supplier':sup}) + context.update({'gd_client':contact, + 'client':gd_client, + 'table':tables, + 'customer':cust, + 'supplier':sup}) imp = google_import(self, cr, uid, 'google', "synchronize_google_contact", gmail_user, context) imp.set_table_list(tables) imp.start() -- cgit v1.2.3 From 7b3233f9135e90b78d5eb01ebdebb74c5086a65f Mon Sep 17 00:00:00 2001 From: "DBR (OpenERP)" Date: Mon, 13 Jun 2011 15:11:49 +0530 Subject: [IMP]import_google : propar authentication bzr revid: dbr@tinyerp.com-20110613094149-8jfqf64vylfnrflc --- addons/import_google/wizard/import_google_data.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'addons/import_google/wizard/import_google_data.py') diff --git a/addons/import_google/wizard/import_google_data.py b/addons/import_google/wizard/import_google_data.py index 813cdc1d3e7..2f814708a74 100644 --- a/addons/import_google/wizard/import_google_data.py +++ b/addons/import_google/wizard/import_google_data.py @@ -120,11 +120,11 @@ class synchronize_google_contact(osv.osv_memory): sup = obj.supplier tables=[] user_obj = self.pool.get('res.users').browse(cr, uid, uid) - if not gmail_user or not gmail_pwd: - raise osv.except_osv(_('Error'), _("Invalid login detail !\n Specify Username/Password.")) - + gmail_user = user_obj.gmail_user gmail_pwd = user_obj.gmail_password + if not gmail_user or not gmail_pwd: + raise osv.except_osv(_('Error'), _("Invalid login detail !\n Specify Username/Password.")) google = self.pool.get('google.login') gd_client = google.google_login(gmail_user, gmail_pwd, type='contact') -- cgit v1.2.3 From 9680b584707d206e7be57e2268f47127115ddf36 Mon Sep 17 00:00:00 2001 From: "DBR (OpenERP)" Date: Mon, 13 Jun 2011 18:22:21 +0530 Subject: [IMP]:Remove the extra class and merge the code bzr revid: dbr@tinyerp.com-20110613125221-f7we3vi67hnw38sm --- addons/import_google/wizard/import_google_data.py | 114 +++++++--------------- 1 file changed, 37 insertions(+), 77 deletions(-) (limited to 'addons/import_google/wizard/import_google_data.py') diff --git a/addons/import_google/wizard/import_google_data.py b/addons/import_google/wizard/import_google_data.py index 2f814708a74..d7b649cd81d 100644 --- a/addons/import_google/wizard/import_google_data.py +++ b/addons/import_google/wizard/import_google_data.py @@ -34,7 +34,7 @@ from import_google import google_import class google_login_contact(osv.osv_memory): _inherit = 'google.login' - _name = 'google.login' + _name = 'google.login.contact' def _get_next_action(self, cr, uid, context=None): data_obj = self.pool.get('ir.model.data') @@ -50,7 +50,7 @@ class google_login_contact(osv.osv_memory): 'name': _('Import google'), 'view_type': 'form', 'view_mode': 'form,tree', - 'res_model': 'synchronize.google.contact.import', + 'res_model': 'synchronize.google.import', 'view_id': False, 'context': context, 'views': [(view_id, 'form')], @@ -61,8 +61,8 @@ class google_login_contact(osv.osv_memory): google_login_contact() -class synchronize_google_contact(osv.osv_memory): - _name = 'synchronize.google.contact.import' +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) @@ -123,87 +123,47 @@ class synchronize_google_contact(osv.osv_memory): gmail_user = user_obj.gmail_user gmail_pwd = user_obj.gmail_password - if not gmail_user or not gmail_pwd: - raise osv.except_osv(_('Error'), _("Invalid login detail !\n Specify Username/Password.")) - google = self.pool.get('google.login') - gd_client = google.google_login(gmail_user, gmail_pwd, type='contact') - 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() - if obj.create_partner=='create_all': - tables.append('Contact') - else: - tables.append('Address') - - context.update({'gd_client':contact, - 'client':gd_client, - 'table':tables, - 'customer':cust, - 'supplier':sup}) - imp = google_import(self, cr, uid, 'google', "synchronize_google_contact", gmail_user, context) - imp.set_table_list(tables) - imp.start() - return{} -# context.update({'message': "Data Imported Successffully from Google."}) -# model_pool = self.pool.get('ir.model.data') -# model_data_ids = model_pool.search(cr, uid, [('model', '=', 'ir.ui.view'), ('name', '=', 'google.import.message.form')]) -# resource_id = model_pool.read(cr, uid, model_data_ids, fields) -# 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, -# } - - def import_calendar_events(self, cr, uid, ids, context=None): - if context == None: - context = {} - if not ids: - return {'type': 'ir.actions.act_window_close'} - table = ['Events'] - user_obj = self.pool.get('res.users').browse(cr, uid, uid) - gmail_user = user_obj.gmail_user - gmail_pwd = user_obj.gmail_password if not gmail_user or not gmail_pwd: raise osv.except_osv(_('Error'), _("Invalid login detail !\n Specify Username/Password.")) - current_rec = self.browse(cr, uid, ids, context=context) - calendars = False - for rec in current_rec: - if rec.calendar_name != 'all': + + if context.get('contact'): + gd_client = google.google_login(gmail_user, gmail_pwd, type='contact') + 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() + if obj.create_partner=='create_all': + tables.append('Contact') + else: + tables.append('Address') + context.update({'gd_client':contact, + 'client':gd_client, + 'table':tables, + 'customer':cust, + 'supplier':sup}) + + elif context.get('calendar'): + tables.append('Events') + calendars = False + if obj.calendar_name != 'all': calendars = [rec.calendar_name] else: calendars = map(lambda x: x[0], [cal for cal in self._get_calendars(cr, uid, context) if cal[0] != 'all']) - context.update({'user': gmail_user, + context.update({'user': gmail_user, 'password': gmail_pwd, 'calendars': calendars, 'instance': 'calendar'}) - imp = google_import(self, cr, uid, 'import_google', "import_google_calendar", [gmail_user], context) - imp.set_table_list(table) - imp.start() - - context.update({'message': "Data Imported Successffully from Google."}) - model_pool = self.pool.get('ir.model.data') - model_data_ids = model_pool.search(cr, uid, [('model', '=', 'ir.ui.view'), ('name', '=', 'google.import.message.form')]) - resource_id = model_pool.read(cr, uid, model_data_ids, fields) - 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_contact() + + imp = google_import(self, cr, uid,'import_google' , "synchronize_google", gmail_user, context) + imp.set_table_list(tables) + imp.start() + return{} + +synchronize_google() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: -- cgit v1.2.3 From a5f2c367bfb216f98641e5b4bbcec05b59a1de98 Mon Sep 17 00:00:00 2001 From: "DBR (OpenERP)" Date: Mon, 13 Jun 2011 18:36:34 +0530 Subject: [REF]:Remove extra authentication bzr revid: dbr@tinyerp.com-20110613130634-x5ky8g5vaopy5bw2 --- addons/import_google/wizard/import_google_data.py | 5 ----- 1 file changed, 5 deletions(-) (limited to 'addons/import_google/wizard/import_google_data.py') diff --git a/addons/import_google/wizard/import_google_data.py b/addons/import_google/wizard/import_google_data.py index d7b649cd81d..d8bdd136002 100644 --- a/addons/import_google/wizard/import_google_data.py +++ b/addons/import_google/wizard/import_google_data.py @@ -31,7 +31,6 @@ from osv import osv from tools.translate import _ from import_google import google_import - class google_login_contact(osv.osv_memory): _inherit = 'google.login' _name = 'google.login.contact' @@ -124,13 +123,9 @@ class synchronize_google(osv.osv_memory): gmail_user = user_obj.gmail_user gmail_pwd = user_obj.gmail_password google = self.pool.get('google.login') - if not gmail_user or not gmail_pwd: - raise osv.except_osv(_('Error'), _("Invalid login detail !\n Specify Username/Password.")) if context.get('contact'): gd_client = google.google_login(gmail_user, gmail_pwd, type='contact') - 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 -- cgit v1.2.3 From a79f88db978e6ed779c1ef08907a8bea3b5e7a6c Mon Sep 17 00:00:00 2001 From: "DBR (OpenERP)" Date: Mon, 13 Jun 2011 19:04:53 +0530 Subject: [IMP]:Improve code for selected events bzr revid: dbr@tinyerp.com-20110613133453-n2348lrgfb8939vz --- addons/import_google/wizard/import_google_data.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'addons/import_google/wizard/import_google_data.py') diff --git a/addons/import_google/wizard/import_google_data.py b/addons/import_google/wizard/import_google_data.py index d8bdd136002..8ffcfd92182 100644 --- a/addons/import_google/wizard/import_google_data.py +++ b/addons/import_google/wizard/import_google_data.py @@ -31,6 +31,7 @@ from osv import osv from tools.translate import _ from import_google import google_import + class google_login_contact(osv.osv_memory): _inherit = 'google.login' _name = 'google.login.contact' @@ -123,9 +124,13 @@ class synchronize_google(osv.osv_memory): gmail_user = user_obj.gmail_user gmail_pwd = user_obj.gmail_password google = self.pool.get('google.login') + if not gmail_user or not gmail_pwd: + raise osv.except_osv(_('Error'), _("Invalid login detail !\n Specify Username/Password.")) if context.get('contact'): gd_client = google.google_login(gmail_user, gmail_pwd, type='contact') + 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 @@ -144,11 +149,13 @@ class synchronize_google(osv.osv_memory): elif context.get('calendar'): tables.append('Events') + current_rec = self.browse(cr, uid, ids, context=context) calendars = False - if obj.calendar_name != 'all': - calendars = [rec.calendar_name] - else: - calendars = map(lambda x: x[0], [cal for cal in self._get_calendars(cr, uid, context) if cal[0] != 'all']) + for rec in current_rec: + if rec.calendar_name != 'all': + calendars = [rec.calendar_name] + else: + calendars = map(lambda x: x[0], [cal for cal in self._get_calendars(cr, uid, context) if cal[0] != 'all']) context.update({'user': gmail_user, 'password': gmail_pwd, 'calendars': calendars, -- cgit v1.2.3 From 03d536c1cf7eca774d3607b7b832b9333f0843ab Mon Sep 17 00:00:00 2001 From: "DBR (OpenERP)" Date: Wed, 15 Jun 2011 17:21:46 +0530 Subject: [ADD]import_google: Changes in yml file of contact and calander bzr revid: dbr@tinyerp.com-20110615115146-su4fj3kwwu7kl0q3 --- addons/import_google/wizard/import_google_data.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'addons/import_google/wizard/import_google_data.py') diff --git a/addons/import_google/wizard/import_google_data.py b/addons/import_google/wizard/import_google_data.py index 8ffcfd92182..3267c018928 100644 --- a/addons/import_google/wizard/import_google_data.py +++ b/addons/import_google/wizard/import_google_data.py @@ -34,7 +34,6 @@ from import_google import google_import class google_login_contact(osv.osv_memory): _inherit = 'google.login' - _name = 'google.login.contact' def _get_next_action(self, cr, uid, context=None): data_obj = self.pool.get('ir.model.data') @@ -110,7 +109,7 @@ class synchronize_google(osv.osv_memory): 'calendar_name': 'all', } - def import_contact(self, cr, uid, ids, context=None): + def import_google(self, cr, uid, ids, context=None): if context == None: context = {} if not ids: @@ -164,7 +163,7 @@ class synchronize_google(osv.osv_memory): imp = google_import(self, cr, uid,'import_google' , "synchronize_google", gmail_user, context) imp.set_table_list(tables) imp.start() - return{} + return context synchronize_google() -- cgit v1.2.3 From dbea57b5805660d06ec4fc57b39b314b122faa5e Mon Sep 17 00:00:00 2001 From: "DBR (OpenERP)" Date: Thu, 16 Jun 2011 10:33:29 +0530 Subject: [IMP]import_google:Improve Gmail id and return value bzr revid: dbr@tinyerp.com-20110616050329-vp5t4u2hj2s6ek9f --- addons/import_google/wizard/import_google_data.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/import_google/wizard/import_google_data.py') diff --git a/addons/import_google/wizard/import_google_data.py b/addons/import_google/wizard/import_google_data.py index 3267c018928..46130dbb62a 100644 --- a/addons/import_google/wizard/import_google_data.py +++ b/addons/import_google/wizard/import_google_data.py @@ -163,7 +163,7 @@ class synchronize_google(osv.osv_memory): imp = google_import(self, cr, uid,'import_google' , "synchronize_google", gmail_user, context) imp.set_table_list(tables) imp.start() - return context + return {} synchronize_google() -- cgit v1.2.3 From 02822e9648f7c2153cf6a30eaed3723cdc1dee64 Mon Sep 17 00:00:00 2001 From: "DBR (OpenERP)" Date: Thu, 16 Jun 2011 15:51:05 +0530 Subject: [IMP]import_google : Improve the code for message box bzr revid: dbr@tinyerp.com-20110616102105-y401kwlng6nl068g --- addons/import_google/wizard/import_google_data.py | 29 ++++++++++++++++------- 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'addons/import_google/wizard/import_google_data.py') diff --git a/addons/import_google/wizard/import_google_data.py b/addons/import_google/wizard/import_google_data.py index 46130dbb62a..3499d449b09 100644 --- a/addons/import_google/wizard/import_google_data.py +++ b/addons/import_google/wizard/import_google_data.py @@ -131,17 +131,14 @@ class synchronize_google(osv.osv_memory): 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}) @@ -163,7 +160,23 @@ class synchronize_google(osv.osv_memory): 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() -- cgit v1.2.3 From 9d885ead0ce3e8bff8890097fca98bcb8405d884 Mon Sep 17 00:00:00 2001 From: Jigar Amin Date: Thu, 23 Jun 2011 18:37:23 +0530 Subject: [FIX] Removed the timezone object from context to avoid pickle problem bzr revid: jam@tinyerp.com-20110623130723-jrxbt9jizmes55mb --- addons/import_google/wizard/import_google_data.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'addons/import_google/wizard/import_google_data.py') diff --git a/addons/import_google/wizard/import_google_data.py b/addons/import_google/wizard/import_google_data.py index 3d8df55cbb1..9c270b77991 100644 --- a/addons/import_google/wizard/import_google_data.py +++ b/addons/import_google/wizard/import_google_data.py @@ -163,8 +163,11 @@ class synchronize_google(osv.osv_memory): imp = google_import(self, cr, uid,'import_google' , "synchronize_google", gmail_user, context) imp.set_table_list(tables) - imp.start() - context.update({'message': msg}) + imp.start() + #Note: Cleaning timezone object from context to avoid pickle problem + if 'au_tz' in context: + context.pop('au_tz') + 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'] -- cgit v1.2.3 From b9f9f3f4d65562e85a841e6ee28fcba1a44f0f10 Mon Sep 17 00:00:00 2001 From: Jigar Amin Date: Fri, 24 Jun 2011 17:36:07 +0530 Subject: [FIX] pickle bug bzr revid: jam@tinyerp.com-20110624120607-rce5msvoiprj7c6j --- addons/import_google/wizard/import_google_data.py | 5 ----- 1 file changed, 5 deletions(-) (limited to 'addons/import_google/wizard/import_google_data.py') diff --git a/addons/import_google/wizard/import_google_data.py b/addons/import_google/wizard/import_google_data.py index 9c270b77991..fae404d103a 100644 --- a/addons/import_google/wizard/import_google_data.py +++ b/addons/import_google/wizard/import_google_data.py @@ -160,18 +160,13 @@ class synchronize_google(osv.osv_memory): 'password': gmail_pwd, 'calendars': calendars, 'instance': 'calendar'}) - imp = google_import(self, cr, uid,'import_google' , "synchronize_google", gmail_user, context) imp.set_table_list(tables) imp.start() - #Note: Cleaning timezone object from context to avoid pickle problem - if 'au_tz' in context: - context.pop('au_tz') 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', -- cgit v1.2.3 From dae2957394b72588760f3417b03e7dc2d23f989b Mon Sep 17 00:00:00 2001 From: "tfr@openerp.com" <> Date: Tue, 5 Jul 2011 14:04:48 +0200 Subject: [FIX] buildbot error bzr revid: tfr@openerp.com-20110705120448-hubv145y04lpkkf1 --- addons/import_google/wizard/import_google_data.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'addons/import_google/wizard/import_google_data.py') diff --git a/addons/import_google/wizard/import_google_data.py b/addons/import_google/wizard/import_google_data.py index fae404d103a..776cb578f08 100644 --- a/addons/import_google/wizard/import_google_data.py +++ b/addons/import_google/wizard/import_google_data.py @@ -71,7 +71,7 @@ class synchronize_google(osv.osv_memory): 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: - raise osv.except_osv(_('Error'), _("Authentication fail check the user and password !")) + return [('failed', 'Connection to google fail')] res = [] query = gdata.contacts.service.GroupsQuery(feed='/m8/feeds/groups/default/full') @@ -92,7 +92,7 @@ class synchronize_google(osv.osv_memory): for cal in calendars.entry: res.append((cal.id.text, cal.title.text)) except Exception, e: - raise osv.except_osv('Error !', e.args[0].get('body')) + return [('failed', 'Connection to google fail')] res.append(('all', 'All Calendars')) return res -- cgit v1.2.3