[IMP] sync_google_contact: Improvements in wizard. Added security file.

bzr revid: uco@tinyerp.com-20110510125612-qk7exk5jqmrwxdiq
This commit is contained in:
Ujjvala Collins (OpenERP)
2011-05-10 18:26:12 +05:30
parent a6fae8f8b5
commit 4c8ea1bc4d
12 changed files with 163 additions and 41 deletions
+1
View File
@@ -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):
+1
View File
@@ -37,6 +37,7 @@
<separator string="Synchronization" colspan="4" />
<field name="crm_caldav" />
<field name="fetchmail" />
<field name="sync_google_contact"/>
</group>
<group colspan="2" col="2">
<separator string="Plug-In" colspan="4" />
@@ -25,5 +25,18 @@
</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>
+1
View File
@@ -21,6 +21,7 @@
import sync_google_contact
import wizard
import google_login_installer
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -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': [],
@@ -0,0 +1,59 @@
# -*- 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_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()
@@ -0,0 +1,65 @@
<openerp>
<data>
<record id="view_crm_inherit_id" model="ir.ui.view">
<field name="name">Google From</field>
<field name="model">google.installer.crm</field>
<field name="type">form</field>
<field name="inherit_id" ref="base.res_config_installer"/>
<field name="arch" type="xml">
<form position="attributes">
<attribute name="string">Import your contacts from Google</attribute>
</form>
<separator string="title" position="attributes">
<attribute name="string">Enter Your Google Connection Data</attribute>
</separator>
<xpath expr="//label[@string='description']" position="attributes">
<attribute name="string">Enter your Google login and password. It will give you the possibility to import and synchronize your Gmail contacts.</attribute>
</xpath>
<xpath expr="//button[@string='Install Modules']" position="replace">
<button name="login" icon="gtk-go-forward" type="object" string="Configure" colspan="1"/>
</xpath>
<xpath expr="//button[@string='Skip']" position="replace">
<button name="action_skip" icon="gtk-jump-to" special="cancel" type="object" string="Skip" colspan="1" invisible="context.get('menu',False)"/>
</xpath>
<xpath expr='//separator[@string="vsep"]' position='attributes'>
<attribute name='string'></attribute>
<attribute name='rowspan'>5</attribute>
</xpath>
<group colspan="8" position="replace">
<group colspan="8" height="50" width="350">
<field name="user"/>
<newline/>
<label string="ex: usr@gmail.com" align="1.0" colspan="2"/>
<newline/>
<field name="password" password="True"/>
</group>
</group>
</field>
</record>
<record id="act_google_installer" model="ir.actions.act_window">
<field name="name">Google Login View</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">google.installer.crm</field>
<field name="view_id" ref="view_crm_inherit_id"/>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
<record id="google_installer_todo" model="ir.actions.todo">
<field name="action_id" ref="act_google_installer"/>
<field name="restart">always</field>
<field name="sequence">3</field>
<field eval="[(6,0,[ref('base.group_extended')])]" name="groups_id"/>
</record>
</data>
</openerp>
@@ -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
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 access_res_users_partner_manager google.res.partner.manager base.model_ir_model_data base.group_partner_manager 1 1 1 0
3 access_ir_model_data_partner_manager ir.model.data.partner.manager base.model_res_users base.group_partner_manager 1 1 0 0
@@ -4,13 +4,13 @@
- |
I create a record for the gmail account for which I want to import the contacts.
-
!record {model: google.login.contact, id: google_login_contact_id0}:
!record {model: google.login, id: google_login_contact_id0}:
user: testmail.openerp
password: openerptiny
- |
I login into that account.
-
!python {model: google.login.contact}: |
!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.
@@ -4,13 +4,13 @@
- |
I create a record for the gmail account for which I want to import the contacts.
-
!record {model: google.login.contact, id: google_login_contact_id1}:
!record {model: google.login, id: google_login_contact_id1}:
user: testmail.openerp
password: openerptiny
- |
I login into that account.
-
!python {model: google.login.contact}: |
!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.
@@ -35,31 +35,6 @@ from osv import fields,osv
from tools.translate import _
import tools
class google_contact_import(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, 'sync_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_contact_import()
class synchronize_google_contact(osv.osv_memory):
_name = 'synchronize.google.contact.import'
@@ -3,17 +3,23 @@
<data>
<record model="ir.ui.view" id="view_synchronize_google_contact_import_form">
<field name="name">synchronize.base.form</field>
<field name="model">synchronize.base</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" />
<separator string="Import Options" colspan="4"/>
<field name="create_partner"/>
<field name="group_name" colspan="4"/>
<newline/>
<group attrs="{'invisible': [('create_partner','!=','create_all')]}" colspan="2" col="4">
<group colspan="2" col="2"/>
<button name="%(google_base_account.act_google_login_form)d" string="Check Connection" type="action" icon="terp-check"/>
<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:"/>
<field name="customer"/>
<newline/>
<label string=""/>
<field name="supplier"/>
</group>
</group>
@@ -30,23 +36,20 @@
</record>
<!--
Login Action
-->
<record model="ir.actions.act_window" id="act_google_login_form">
<record model="ir.actions.act_window" id="act_import_google_contacts_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="res_model">synchronize.google.contact.import</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
<field name="view_id" ref="google_base_account.view_google_login_form" />
<field name="view_id" ref="view_synchronize_google_contact_import_form" />
</record>
<menuitem id="menu_sync_contact"
parent="base.menu_address_book"
action="act_google_login_form"
action="act_import_google_contacts_form"
sequence="40" />
</data>
</openerp>