From 4c8ea1bc4d75de7e5c216e4ab22373145ed3f661 Mon Sep 17 00:00:00 2001 From: "Ujjvala Collins (OpenERP)" Date: Tue, 10 May 2011 18:26:12 +0530 Subject: [PATCH] [IMP] sync_google_contact: Improvements in wizard. Added security file. bzr revid: uco@tinyerp.com-20110510125612-qk7exk5jqmrwxdiq --- addons/crm/crm_installer.py | 1 + addons/crm/crm_installer_view.xml | 1 + .../wizard/google_login_view.xml | 13 ++++ addons/sync_google_contact/__init__.py | 1 + addons/sync_google_contact/__openerp__.py | 1 + .../google_login_installer.py | 59 +++++++++++++++++ .../google_login_installer.xml | 65 +++++++++++++++++++ .../security/ir.model.access.csv | 3 + ...est_sync_google_contact_import_address.yml | 4 +- ...est_sync_google_contact_import_partner.yml | 4 +- .../wizard/google_contact_import.py | 25 ------- .../wizard/google_contact_import_view.xml | 27 ++++---- 12 files changed, 163 insertions(+), 41 deletions(-) create mode 100644 addons/sync_google_contact/google_login_installer.py create mode 100644 addons/sync_google_contact/google_login_installer.xml create mode 100644 addons/sync_google_contact/security/ir.model.access.csv diff --git a/addons/crm/crm_installer.py b/addons/crm/crm_installer.py index 32551d438c4..9e62d51a2a5 100644 --- a/addons/crm/crm_installer.py +++ b/addons/crm/crm_installer.py @@ -37,6 +37,7 @@ class crm_installer(osv.osv_memory): 'thunderbird': fields.boolean('Thunderbird', help="Allows you to link your e-mail to OpenERP's documents. You can attach it to any existing one in OpenERP or create a new one."), 'outlook': fields.boolean('MS-Outlook', help="Allows you to link your e-mail to OpenERP's documents. You can attach it to any existing one in OpenERP or create a new one."), 'wiki_sale_faq': fields.boolean('Sale FAQ', help="Helps you manage wiki pages for Frequently Asked Questions on Sales Application."), + 'sync_google_contact': fields.boolean('Google Contacts'), } def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): diff --git a/addons/crm/crm_installer_view.xml b/addons/crm/crm_installer_view.xml index 35ff5a0a7cc..ae9dc5026e6 100644 --- a/addons/crm/crm_installer_view.xml +++ b/addons/crm/crm_installer_view.xml @@ -37,6 +37,7 @@ + diff --git a/addons/google_base_account/wizard/google_login_view.xml b/addons/google_base_account/wizard/google_login_view.xml index 653cf41d211..9c5c93c613e 100644 --- a/addons/google_base_account/wizard/google_login_view.xml +++ b/addons/google_base_account/wizard/google_login_view.xml @@ -25,5 +25,18 @@ + + + + Google Login + ir.actions.act_window + google.login + form + form + new + + diff --git a/addons/sync_google_contact/__init__.py b/addons/sync_google_contact/__init__.py index 202f8f989f2..01ccebf7811 100644 --- a/addons/sync_google_contact/__init__.py +++ b/addons/sync_google_contact/__init__.py @@ -21,6 +21,7 @@ import sync_google_contact import wizard +import google_login_installer # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/sync_google_contact/__openerp__.py b/addons/sync_google_contact/__openerp__.py index 6d19f2c6865..4f1eaf7d42d 100644 --- a/addons/sync_google_contact/__openerp__.py +++ b/addons/sync_google_contact/__openerp__.py @@ -30,6 +30,7 @@ 'depends': ['base','google_base_account'], 'init_xml': [], 'update_xml': [ + 'google_login_installer.xml', 'wizard/google_contact_import_view.xml' ], 'demo_xml': [], diff --git a/addons/sync_google_contact/google_login_installer.py b/addons/sync_google_contact/google_login_installer.py new file mode 100644 index 00000000000..8ae52f34d9c --- /dev/null +++ b/addons/sync_google_contact/google_login_installer.py @@ -0,0 +1,59 @@ +# -*- 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 . +# +############################################################################## + +from osv import fields, osv +from tools.translate import _ +try: + import gdata.contacts.service +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')) + +class google_installer_crm(osv.osv_memory): + _name = 'google.installer.crm' + _inherit = 'res.config.installer' + _columns = { + 'user': fields.char('Google Username', size=64, required=True), + 'password': fields.char('Google Password', size=64) + } + + def google_login(self, user, password, type='group', context=None): + gd_client = gdata.contacts.service.ContactsService() + try: + gd_client.ClientLogin(user, password,gd_client.source) + except Exception: + return False + return gd_client + + def login(self, cr, uid, ids, context=None): + data = self.read(cr, uid, ids)[0] + user = data['user'] + password = data['password'] + if self.google_login(user, password): + res = { + 'gmail_user': user, + 'gmail_password': password + } + self.pool.get('res.users').write(cr, uid, uid, res, context=context) + else: + raise osv.except_osv(_('Error'), _("Authentication failed! Check the user and password !")) + return {} + +google_installer_crm() diff --git a/addons/sync_google_contact/google_login_installer.xml b/addons/sync_google_contact/google_login_installer.xml new file mode 100644 index 00000000000..28f9d31fada --- /dev/null +++ b/addons/sync_google_contact/google_login_installer.xml @@ -0,0 +1,65 @@ + + + + Google From + google.installer.crm + form + + + +
+ Import your contacts from Google +
+ + Enter Your Google Connection Data + + + Enter your Google login and password. It will give you the possibility to import and synchronize your Gmail contacts. + + + + +