← Back to team overview

openerp-dev-web team mailing list archive

lp:~openerp-dev/openobject-addons/trunk-contact-google-sync-backlog_correction-dbr into lp:openobject-addons

 

Devishree Brahmbhatt (OpenERP) has proposed merging lp:~openerp-dev/openobject-addons/trunk-contact-google-sync-backlog_correction-dbr into lp:openobject-addons.

Requested reviews:
  Bhumika (OpenERP) (sbh-openerp)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-contact-google-sync-backlog_correction-dbr/+merge/62657
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-contact-google-sync-backlog_correction-dbr/+merge/62657
Your team OpenERP R&D Team is subscribed to branch lp:~openerp-dev/openobject-addons/trunk-contact-google-sync-backlog_correction-dbr.
=== modified file 'crm/crm_installer.py'
--- crm/crm_installer.py	2011-01-14 00:11:01 +0000
+++ crm/crm_installer.py	2011-05-27 11:52:28 +0000
@@ -37,6 +37,7 @@
         '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."),
+        'import_google_contact': fields.boolean('Google Contacts', help="Imports contacts from your google account."),
     }
 
     def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):

=== modified file 'crm/crm_installer_view.xml'
--- crm/crm_installer_view.xml	2011-01-14 00:11:01 +0000
+++ crm/crm_installer_view.xml	2011-05-27 11:52:28 +0000
@@ -19,7 +19,7 @@
             <attribute name="string">Enhance your core CRM Application with additional functionalities.</attribute>
           </xpath>
           <xpath expr='//separator[@string="vsep"]' position='attributes'>
-              <attribute name='rowspan'>13</attribute>
+              <attribute name='rowspan'>8</attribute>
               <attribute name='string'></attribute>
           </xpath>
           <xpath expr="//button[@string='Install Modules']" position="attributes">
@@ -37,6 +37,7 @@
                 <separator string="Synchronization" colspan="4" />
                 <field name="crm_caldav" />
                 <field name="fetchmail" />
+                <field name="import_google_contact"/>
             </group>
             <group colspan="2" col="2">
               <separator string="Plug-In" colspan="4" />

=== modified file 'crm/crm_lead.py'
--- crm/crm_lead.py	2011-04-26 07:39:18 +0000
+++ crm/crm_lead.py	2011-05-27 11:52:28 +0000
@@ -270,7 +270,6 @@
         data_obj = self.pool.get('ir.model.data')
         value = {}
 
-        view_id = False
 
         for case in self.browse(cr, uid, ids, context=context):
             context.update({'active_id': case.id})

=== modified file 'crm/wizard/crm_lead_to_partner.py'
--- crm/wizard/crm_lead_to_partner.py	2011-04-29 08:49:48 +0000
+++ crm/wizard/crm_lead_to_partner.py	2011-05-27 11:52:28 +0000
@@ -149,7 +149,6 @@
         contact_obj = self.pool.get('res.partner.address')
         partner_ids = []
         partner_id = False
-        contact_id = False
         rec_ids = context and context.get('active_ids', [])
 
         for data in self.browse(cr, uid, ids, context=context):
@@ -160,7 +159,7 @@
                         'user_id': lead.user_id.id,
                         'comment': lead.description,
                     })
-                    contact_id = contact_obj.create(cr, uid, {
+                    contact_obj.create(cr, uid, {
                         'partner_id': partner_id,
                         'name': lead.contact_name,
                         'phone': lead.phone,
@@ -180,7 +179,6 @@
                 else:
                     if data.partner_id:
                         partner_id = data.partner_id.id
-                        contact_id = partner_obj.address_get(cr, uid, [partner_id])['default']
                 self.assign_partner(cr, uid, lead.id, partner_id)
                 partner_ids.append(partner_id)
         return partner_ids

=== modified file 'crm/wizard/crm_merge_opportunities.py'
--- crm/wizard/crm_merge_opportunities.py	2011-05-06 08:14:47 +0000
+++ crm/wizard/crm_merge_opportunities.py	2011-05-27 11:52:28 +0000
@@ -182,8 +182,6 @@
 
 
         # Get Opportunity views
-        result = models_data._get_id(
-            cr, uid, 'crm', 'view_crm_case_opportunities_filter')
         opportunity_view_form = models_data._get_id(
             cr, uid, 'crm', 'crm_case_form_view_oppor')
         opportunity_view_tree = models_data._get_id(

=== modified file 'crm_partner_assign/wizard/crm_forward_to_partner.py'
--- crm_partner_assign/wizard/crm_forward_to_partner.py	2011-04-07 09:27:30 +0000
+++ crm_partner_assign/wizard/crm_forward_to_partner.py	2011-05-27 11:52:28 +0000
@@ -20,11 +20,9 @@
 #
 ##############################################################################
 
-import base64
 import time
 import re
 from osv import osv, fields
-import tools
 from tools.translate import _
 
 class crm_lead_forward_to_partner(osv.osv_memory):

=== added directory 'google_base_account'
=== added file 'google_base_account/__init__.py'
--- google_base_account/__init__.py	1970-01-01 00:00:00 +0000
+++ google_base_account/__init__.py	2011-05-27 11:52:28 +0000
@@ -0,0 +1,26 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#    
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
+#
+#    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 <http://www.gnu.org/licenses/>.     
+#
+##############################################################################
+
+import google_base_account
+import wizard
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+

=== added file 'google_base_account/__openerp__.py'
--- google_base_account/__openerp__.py	1970-01-01 00:00:00 +0000
+++ google_base_account/__openerp__.py	2011-05-27 11:52:28 +0000
@@ -0,0 +1,41 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
+#
+#    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 <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+
+{
+    'name': 'Google user',
+    'version': '1.0',
+    'category': 'Generic Modules/Others',
+    'description': """The module adds google user  in res user""",
+    'author': 'OpenERP SA',
+    'website': 'http://www.openerp.com',
+    'depends': ['base'],
+    'init_xml': [],
+    'update_xml': [
+                  'google_base_account_view.xml',
+                  'wizard/google_login_view.xml',
+                   ],
+    'demo_xml': [],
+    'installable': True,
+    'active': False,
+    'certificate': '',
+}
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

=== added file 'google_base_account/google_base_account.py'
--- google_base_account/google_base_account.py	1970-01-01 00:00:00 +0000
+++ google_base_account/google_base_account.py	2011-05-27 11:52:28 +0000
@@ -0,0 +1,33 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
+#
+#    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 <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from osv import fields,osv
+    
+class res_users(osv.osv):
+    _inherit = "res.users"
+    _columns = {
+        'gmail_user': fields.char('Username', size=64,),
+        'gmail_password': fields.char('Password', size=64),
+    }
+res_users()    
+
+# vim:expandtab:smartindent:toabstop=4:softtabstop=4:shiftwidth=4:
+

=== added file 'google_base_account/google_base_account_view.xml'
--- google_base_account/google_base_account_view.xml	1970-01-01 00:00:00 +0000
+++ google_base_account/google_base_account_view.xml	2011-05-27 11:52:28 +0000
@@ -0,0 +1,20 @@
+<?xml version="1.0"?>
+<openerp>
+    <data>
+		<record id="view_users_gogole_form" model="ir.ui.view">
+        <field name="name">res.users.google.form1</field>
+          <field name="model">res.users</field>
+          <field name="type">form</field>
+          <field name="inherit_id" ref="base.view_users_form"/>
+          <field name="arch" type="xml">
+              <xpath expr="//notebook[last()]" position="inside">
+                     <page string=" Synchronization ">
+                     	<separator string="Google Account" colspan="4" />
+						<field name="gmail_user"/>
+                      <field name="gmail_password" password="True"/>
+					</page>
+              </xpath>
+          </field>
+     </record>
+    </data>
+</openerp>

=== added directory 'google_base_account/wizard'
=== added file 'google_base_account/wizard/__init__.py'
--- google_base_account/wizard/__init__.py	1970-01-01 00:00:00 +0000
+++ google_base_account/wizard/__init__.py	2011-05-27 11:52:28 +0000
@@ -0,0 +1,25 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#    
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
+#
+#    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 <http://www.gnu.org/licenses/>.     
+#
+##############################################################################
+
+import google_login
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+

=== added file 'google_base_account/wizard/google_login.py'
--- google_base_account/wizard/google_login.py	1970-01-01 00:00:00 +0000
+++ google_base_account/wizard/google_login.py	2011-05-27 11:52:28 +0000
@@ -0,0 +1,75 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
+#
+#    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 <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+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_login(osv.osv_memory):
+    _description ='Google Contact'
+    _name = 'google.login'
+    _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 default_get(self, cr, uid, fields, context=None):
+        res = super(google_login, self).default_get(cr, uid, fields, context=context)
+        user_obj = self.pool.get('res.users').browse(cr, uid, uid)
+        if 'user' in fields:
+            res.update({'user': user_obj.gmail_user})
+        if 'password' in fields:
+            res.update({'password': user_obj.gmail_password})
+        return res
+    
+    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 fail check the user and password !"))
+
+        return self._get_next_action(cr, uid, context=context)
+
+    def _get_next_action(self, cr, uid, context=None):
+        return {'type': 'ir.actions.act_window_close'}
+
+google_login()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

=== added file 'google_base_account/wizard/google_login_view.xml'
--- google_base_account/wizard/google_login_view.xml	1970-01-01 00:00:00 +0000
+++ google_base_account/wizard/google_login_view.xml	2011-05-27 11:52:28 +0000
@@ -0,0 +1,42 @@
+<?xml version="1.0"?>
+<openerp>
+    <data>
+        <record model="ir.ui.view" id="view_google_login_form">
+            <field name="name">google.login.form</field>
+            <field name="model">google.login</field>
+            <field name="type">form</field>
+            <field name="arch" type="xml">
+                <form string="Google login" >
+                    <group colspan="4" col="4" width="300">
+                        <field name="user" />
+                        <newline/>
+                        <label string="ex: user@xxxxxxxxx" align="1.0" colspan="2"/>
+                        <newline/>
+                        <field name="password" password="True"/>
+                    </group>
+                    <separator string="" colspan="4"/>
+                    <group colspan="4" col="4">
+                        <group colspan="2"/>
+                        <group colspan="2">  
+                            <button special="cancel" string="_Cancel" icon="gtk-cancel"/>
+                            <button name="login" string="_Login" type="object" icon="terp-check"/>
+                        </group>
+                    </group>
+                </form>
+            </field>
+        </record>
+        
+        <!-- 
+            Login Action 
+        -->
+        <record model="ir.actions.act_window" id="act_google_login_form">
+          <field name="name">Google Login</field>
+          <field name="type">ir.actions.act_window</field>
+          <field name="res_model">google.login</field>
+          <field name="view_type">form</field>
+          <field name="view_mode">form</field>
+          <field name="target">new</field>
+          <field name="view_id" ref="view_google_login_form" />
+        </record>
+    </data>
+</openerp>

=== added directory 'import_google_contact'
=== added file 'import_google_contact/__init__.py'
--- import_google_contact/__init__.py	1970-01-01 00:00:00 +0000
+++ import_google_contact/__init__.py	2011-05-27 11:52:28 +0000
@@ -0,0 +1,26 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#    
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
+#
+#    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 <http://www.gnu.org/licenses/>.     
+#
+##############################################################################
+
+import import_google_contact
+import wizard
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+

=== added file 'import_google_contact/__openerp__.py'
--- import_google_contact/__openerp__.py	1970-01-01 00:00:00 +0000
+++ import_google_contact/__openerp__.py	2011-05-27 11:52:28 +0000
@@ -0,0 +1,44 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
+#
+#    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 <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+
+{
+    'name': 'Google Contact Import',
+    'version': '1.0',
+    'category': 'Generic Modules/Others',
+    'description': """The module adds google contact in partner address""",
+    'author': 'OpenERP SA',
+    'website': 'http://www.openerp.com',
+    'depends': ['base','google_base_account'],
+    'init_xml': [],
+    'update_xml': [
+                  'wizard/google_contact_import_view.xml'
+                   ],
+    'demo_xml': [],
+    'test': [
+             'test/test_sync_google_contact_import_partner.yml',
+             'test/test_sync_google_contact_import_address.yml',
+    ],
+    'installable': True,
+    'active': False,
+    'certificate': '',
+}
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

=== added file 'import_google_contact/import_google_contact.py'
--- import_google_contact/import_google_contact.py	1970-01-01 00:00:00 +0000
+++ import_google_contact/import_google_contact.py	2011-05-27 11:52:28 +0000
@@ -0,0 +1,39 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
+#
+#    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 <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from osv import fields,osv
+
+class res_partner_address(osv.osv):
+    _inherit = "res.partner.address"
+
+    _columns = {
+        'write_date': fields.datetime('Date Modified', readonly=True, help="Modification date and time of address."),
+    }
+
+    def unlink(self, cr, uid, ids, context=None):
+        model_obj = self.pool.get('ir.model.data')
+        model_ids = model_obj.search(cr, uid, [('res_id','in',ids),('model','=','res.partner.address'),('module','=','sync_google_contact')], context=context)
+        model_obj.unlink(cr, uid, model_ids, context=context)
+        return super(res_partner_address, self).unlink(cr, uid, ids, context=context)
+
+res_partner_address()
+
+# vim:expandtab:smartindent:toabstop=4:softtabstop=4:shiftwidth=4:

=== added directory 'import_google_contact/security'
=== added file 'import_google_contact/security/ir.model.access.csv'
--- import_google_contact/security/ir.model.access.csv	1970-01-01 00:00:00 +0000
+++ import_google_contact/security/ir.model.access.csv	2011-05-27 11:52:28 +0000
@@ -0,0 +1,3 @@
+"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
+"access_res_users_partner_manager","google.res.partner.manager","base.model_ir_model_data","base.group_partner_manager",1,1,1,0
+"access_ir_model_data_partner_manager","ir.model.data.partner.manager","base.model_res_users","base.group_partner_manager",1,1,0,0

=== added directory 'import_google_contact/test'
=== added file 'import_google_contact/test/test_sync_google_contact_import_address.yml'
--- import_google_contact/test/test_sync_google_contact_import_address.yml	1970-01-01 00:00:00 +0000
+++ import_google_contact/test/test_sync_google_contact_import_address.yml	2011-05-27 11:52:28 +0000
@@ -0,0 +1,34 @@
+-
+  In order to test Importing contacts from any google account into OpenERP,
+  I use a gmail account and import the contact details and store them as Partner addresses.
+- |
+  I create a record for the gmail account for which I want to import the contacts.
+- 
+  !record {model: google.login, id: google_login_contact_id0}:
+    user: testmail.openerp
+    password: openerptiny
+- |
+  I login into that account.
+-
+  !python {model: google.login}: |
+    self.login(cr, uid, [ref('google_login_contact_id0')], context)
+- |
+  Now I select from which group I want to get the contact details.
+-
+  !record {model: synchronize.google.contact.import, id: synchronize_google_contact_import_id0}:
+    create_partner: create_address
+    group_name: all
+- |
+  I import the contacts and I also check if the contact already exists in db and updates the address.
+-
+  !python {model: synchronize.google.contact.import}: |
+    self.import_contact(cr, uid, [ref('synchronize_google_contact_import_id0')], context)
+- |
+  I check whether the Contacts are created in Partner address or not.
+-
+  !python {model: ir.model.data}: |
+    addr_obj = self.pool.get('res.partner.address')
+    addr_ids = addr_obj.search(cr, uid, [])
+    data_ids = self.search(cr, uid, [('res_id','in',addr_ids),('model','=','res.partner.address'),('module','=','sync_google_contact')])
+    assert data_ids, 'Addresses not created !'
+    
\ No newline at end of file

=== added file 'import_google_contact/test/test_sync_google_contact_import_partner.yml'
--- import_google_contact/test/test_sync_google_contact_import_partner.yml	1970-01-01 00:00:00 +0000
+++ import_google_contact/test/test_sync_google_contact_import_partner.yml	2011-05-27 11:52:28 +0000
@@ -0,0 +1,36 @@
+-
+  In order to test Importing contacts from any google account into OpenERP,
+  I use a gmail account and import the contact details and create Partners.
+- |
+  I create a record for the gmail account for which I want to import the contacts.
+-
+  !record {model: google.login, id: google_login_contact_id1}:
+    user: testmail.openerp
+    password: openerptiny
+- |
+  I login into that account.
+-
+  !python {model: google.login}: |
+    self.login(cr, uid, [ref('google_login_contact_id1')], context)
+- |
+  Now I select from which group I want to get the contact details and I want to create partner for all contacts.
+-
+  !record {model: synchronize.google.contact.import, id: synchronize_google_contact_import_id1}:
+    create_partner: create_all
+    group_name: all
+- |
+  I import the contacts.
+-
+  !python {model: synchronize.google.contact.import}: |
+    self.import_contact(cr, uid, [ref('synchronize_google_contact_import_id1')], context)
+- |
+  I check whether the Partners are created or not.
+-
+  !python {model: ir.model.data}: |
+    addr_obj = self.pool.get('res.partner.address')
+    addr_ids = addr_obj.search(cr, uid, [])
+    data_ids = self.search(cr, uid, [('res_id','in',addr_ids),('model','=','res.partner.address'),('module','=','sync_google_contact')])
+    address_ids = map(lambda x: x.res_id, [child for child in self.browse(cr, uid, data_ids) if child.res_id])
+    partner_ids = map(lambda x: x.partner_id.id, [addr for addr in addr_obj.browse(cr, uid, address_ids) if addr.partner_id])
+    assert partner_ids, 'Partners not created !'
+    
\ No newline at end of file

=== added directory 'import_google_contact/wizard'
=== added file 'import_google_contact/wizard/__init__.py'
--- import_google_contact/wizard/__init__.py	1970-01-01 00:00:00 +0000
+++ import_google_contact/wizard/__init__.py	2011-05-27 11:52:28 +0000
@@ -0,0 +1,24 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
+#
+#    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 <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+import google_contact_import
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

=== added file 'import_google_contact/wizard/google_contact_import.py'
--- import_google_contact/wizard/google_contact_import.py	1970-01-01 00:00:00 +0000
+++ import_google_contact/wizard/google_contact_import.py	2011-05-27 11:52:28 +0000
@@ -0,0 +1,276 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
+#
+#    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 <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+import datetime
+import dateutil
+from dateutil.parser import *
+from pytz import timezone
+
+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,osv
+from tools.translate import _
+import tools
+
+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')
+        data_id = data_obj._get_id(cr, uid, 'import_google_contact', 'view_synchronize_google_contact_import_form')
+        view_id = False
+        if data_id:
+            view_id = data_obj.browse(cr, uid, data_id, context=context).res_id
+        value = {
+            'name': _('Import Contact'),
+            '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
+
+    _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."),
+     }
+
+    _defaults = {
+        'create_partner': 'create_all',
+        'group_name': 'all',
+    }
+
+    def create_partner(self, cr, uid, data={}, context=None):
+        if context == None:
+            context = {}
+        if not data:
+            return False
+        name = data.get("company") or data.get('name','')
+        partner_pool = self.pool.get('res.partner')
+        partner_id = partner_pool.create(cr, uid, {
+                                                  'name': name,
+                                                  'user_id': uid,
+                                                  'address' : [(6, 0, [data['address_id']])],
+                                                  'customer': data.get('customer', False),
+                                                  'supplier': data.get('supplier', False)
+                                        }, context=context)
+        return partner_id
+    
+    def set_partner(self, cr, uid, name, address_id, context=None):
+        partner_pool = self.pool.get('res.partner')
+        partner_ids = partner_pool.search(cr, uid, [('name', '=', name)], context=context)
+        if partner_ids:
+            address_pool = self.pool.get('res.partner.address')#TODO create partner of find the one with the same name
+            data = {'partner_id' : partner_ids[0]}
+            address_pool.write(cr, uid, [address_id], data, context=context)
+            return partner_ids[0]
+        return False
+
+    def import_contact(self, cr, uid, ids, context=None):
+        obj = self.browse(cr, uid, ids, context=context)[0]
+
+        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()
+
+        ids = self.create_contact(cr, uid, ids, gd_client, contact, option=obj.create_partner,context=context)
+        if not ids:
+            return {'type': 'ir.actions.act_window_close'}
+
+        return {
+                'name': _(obj.create_partner =='create_all' and 'Partners') or _('Contacts'),
+                'domain': "[('id','in', ["+','.join(map(str,ids))+"])]",
+                'view_type': 'form',
+                'view_mode': 'tree,form',
+                'res_model': obj.create_partner =='create_all' and 'res.partner' or 'res.partner.address',
+                'context': context,
+                'views': [(False, 'tree'),(False, 'form')],
+                'type': 'ir.actions.act_window',
+        }
+
+
+    def create_contact(self, cr, uid, ids, gd_client, contact, option,context=None):
+        model_obj = self.pool.get('ir.model.data')
+        addresss_obj = self.pool.get('res.partner.address')
+        company_pool = self.pool.get('res.company')
+        addresses = []
+        partner_ids = []
+        contact_ids = []
+        if 'tz' in context and context['tz']:
+            time_zone = context['tz']
+        else:
+            time_zone = tools.get_server_timezone()
+        au_tz = timezone(time_zone)
+        while contact:
+            for entry in contact.entry:
+                data = self._retreive_data(entry)
+                if 'company' in data:
+                    print data['company']
+                google_id = data.pop('id')
+                model_data = {
+                    'name':  google_id,
+                    'model': 'res.partner.address',
+                    'module': 'sync_google_contact',
+                    'noupdate': True
+                }
+
+                data_ids = model_obj.search(cr, uid, [('model','=','res.partner.address'), ('name','=', google_id)])
+                if data_ids:
+                    contact_ids = [model_obj.browse(cr, uid, data_ids[0], context=context).res_id]
+                elif data['email']:
+                    contact_ids = addresss_obj.search(cr, uid, [('email', 'ilike', data['email'])])
+
+                if contact_ids:
+                    addresses.append(contact_ids[0])
+                    address = addresss_obj.browse(cr, uid, contact_ids[0], context=context)
+                    google_updated = entry.updated.text
+                    utime = dateutil.parser.parse(google_updated)
+                    au_dt = au_tz.normalize(utime.astimezone(au_tz))
+                    updated_dt = datetime.datetime(*au_dt.timetuple()[:6]).strftime('%Y-%m-%d %H:%M:%S')
+                    if address.write_date < updated_dt:
+                        self.update_contact(cr, uid, contact_ids, data, context=context)
+                    res_id = contact_ids[0]
+                if not contact_ids:
+                    #create or link to an existing partner only if it's a new contact
+                    data.update({'type': 'default'})
+                    res_id = addresss_obj.create(cr, uid, data, context=context)
+                    data['address_id'] = res_id
+                    if option == 'create_all':
+                        obj = self.browse(cr, uid, ids, context=context)[0]
+                        data['customer'] = obj.customer
+                        data['supplier'] = obj.supplier
+                        res = False
+                        if 'company' in data:
+                            res = self.set_partner(cr, uid, data.get('company'), res_id, context=context)
+                            if res:
+                                partner_ids.append(res)
+                        if not res:
+                            partner_id = self.create_partner(cr, uid, data, context=context)
+                            partner_ids.append(partner_id)
+                    addresses.append(res_id)
+
+                if not data_ids: #link to google_id if it was not the case before            
+                    model_data.update({'res_id': res_id})
+                    model_obj.create(cr, uid, model_data, context=context)
+
+            next = contact.GetNextLink()
+            contact = next and gd_client.GetContactsFeed(next.href) or None
+
+        if option == 'create_all':
+            return partner_ids
+        else:
+            return addresses
+        
+    def _retreive_data(self, entry):
+        data = {}
+        data['id'] = entry.id.text
+        name = tools.ustr(entry.title.text)
+        if name == "None":
+            name = entry.email[0].address
+        data['name'] = name
+        emails = ','.join(email.address for email in entry.email)
+        data['email'] = emails
+        if entry.organization:
+            if entry.organization.org_name:
+                data.update({'company': entry.organization.org_name.text})
+            if entry.organization.org_title:
+                data.update ({'function': entry.organization.org_title.text})
+
+
+        if entry.phone_number:
+            for phone in entry.phone_number:
+                if phone.rel == gdata.contacts.REL_WORK:
+                    data['phone'] = phone.text
+                if phone.rel == gdata.contacts.PHONE_MOBILE:
+                    data['mobile'] = phone.text
+                if phone.rel == gdata.contacts.PHONE_WORK_FAX:
+                    data['fax'] = phone.text
+        return data
+
+    def update_contact(self, cr, uid, contact_ids, data, context=None):
+        addresss_obj = self.pool.get('res.partner.address')
+        vals = {}
+        addr = addresss_obj.browse(cr,uid,contact_ids)[0]
+        name = str((addr.name or addr.partner_id and addr.partner_id.name or '').encode('utf-8'))
+
+        if name != data.get('name'):
+            vals['name'] = data.get('name','')
+        if addr.email != data.get('email'):
+            vals['email'] = data.get('email','')
+        if addr.mobile != data.get('mobile'):
+            vals['mobile'] = data.get('mobile','')
+        if addr.phone != data.get('phone'):
+            vals['phone'] = data.get('phone','')
+        if addr.fax != data.get('fax'):
+            vals['fax'] = data.get('fax','')
+        
+        addresss_obj.write(cr, uid, contact_ids, vals, context=context)
+        return {'type': 'ir.actions.act_window_close'}
+
+synchronize_google_contact()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

=== added file 'import_google_contact/wizard/google_contact_import_view.xml'
--- import_google_contact/wizard/google_contact_import_view.xml	1970-01-01 00:00:00 +0000
+++ import_google_contact/wizard/google_contact_import_view.xml	2011-05-27 11:52:28 +0000
@@ -0,0 +1,60 @@
+<?xml version="1.0"?>
+<openerp>
+    <data>
+
+		<record model="ir.ui.view" id="view_google_login_contact_form">
+			<field name="name">google.login.contact.form</field>
+			<field name="model">google.login.contact</field>
+			<field name="type">form</field>
+			<field name="inherit_id" ref="google_base_account.view_google_login_form" />
+			<field name="arch" type="xml">
+				<data> </data>
+			</field>
+		</record>
+
+        <record model="ir.ui.view" id="view_synchronize_google_contact_import_form">
+            <field name="name">synchronize.base.form</field>
+            <field name="model">synchronize.google.contact.import</field>
+            <field name="type">form</field>
+            <field name="arch" type="xml">
+                <form string="Import contacts from a google account">
+                    <group colspan="4" col="4" width="430">
+                       <field name="group_name" colspan="4"/>
+                       <separator string="Import Options" colspan="4"/>
+                       <field name="create_partner" colspan="4"/>
+                       <newline/>
+                       <group attrs="{'invisible': [('create_partner','!=','create_all')]}" colspan="4" col="4">
+                            <separator string="Partner status for this group:" colspan="4"/>
+                            <field name="customer" colspan="4"/>
+                            <field name="supplier"  colspan="4"/>
+                       </group>
+                    </group>
+                    <separator string="" colspan="4"/>
+                    <group colspan="4" col="4">
+                        <group colspan="2" col="2"/>
+                        <group colspan="2" col="2">
+                            <button special="cancel" string="_Cancel" icon="gtk-cancel"/>
+                            <button name="import_contact" string="_Import Contacts" type="object" icon="terp-personal+"/>
+                        </group>
+                    </group>
+                </form>
+            </field>
+        </record>
+
+        <record model="ir.actions.act_window" id="act_google_login_contact_form">
+          <field name="name">Import Contacts</field>
+          <field name="type">ir.actions.act_window</field>
+          <field name="res_model">google.login.contact</field>
+          <field name="view_type">form</field>
+          <field name="view_mode">form</field>
+          <field name="target">new</field>
+          <field name="view_id" ref="view_synchronize_google_contact_import_form" />
+        </record>
+
+
+        <menuitem id="menu_sync_contact"
+                  parent="base.menu_address_book"
+                  action="act_import_google_contacts_form"
+                  sequence="40" />
+    </data>
+</openerp>