[IMP] Add wizard to check google login and put warning message
bzr revid: sbh@tinyerp.com-20110214133707-uj3yic3m1lz9oyuz
This commit is contained in:
parent
8692fbcc10
commit
a3a7704e38
|
@ -20,6 +20,7 @@
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
import google_base_account
|
import google_base_account
|
||||||
|
import wizard
|
||||||
|
|
||||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
'init_xml': [],
|
'init_xml': [],
|
||||||
'update_xml': [
|
'update_xml': [
|
||||||
'google_base_account_view.xml',
|
'google_base_account_view.xml',
|
||||||
|
'wizard/google_login_view.xml',
|
||||||
],
|
],
|
||||||
'demo_xml': [],
|
'demo_xml': [],
|
||||||
'installable': True,
|
'installable': True,
|
||||||
|
|
|
@ -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:
|
||||||
|
|
|
@ -0,0 +1,58 @@
|
||||||
|
# -*- 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,orm
|
||||||
|
from tools.translate import _
|
||||||
|
import gdata.contacts
|
||||||
|
import gdata.contacts.service
|
||||||
|
|
||||||
|
from sync_google_contact import sync_google_contact
|
||||||
|
|
||||||
|
class google_login(osv.osv_memory):
|
||||||
|
_description ='Google Contact'
|
||||||
|
_name = 'google.login'
|
||||||
|
_columns = {
|
||||||
|
'user': fields.char('User Name', size=64, required=True),
|
||||||
|
'password': fields.char('Password', size=64),
|
||||||
|
}
|
||||||
|
|
||||||
|
def check_login(self, cr, uid, ids, context=None):
|
||||||
|
if context==None:
|
||||||
|
context={}
|
||||||
|
data=self.read(cr,uid,ids)[0]
|
||||||
|
user=data['user']
|
||||||
|
password=data['password']
|
||||||
|
gd_client = gdata.contacts.service.ContactsService()
|
||||||
|
gd_client.email = user
|
||||||
|
gd_client.password = password
|
||||||
|
gd_client.source = 'OpenERP'
|
||||||
|
try:
|
||||||
|
gd_client.ProgrammaticLogin()
|
||||||
|
res={'gmail_user':user,
|
||||||
|
'gmail_password':password}
|
||||||
|
self.pool.get('res.users').write(cr,uid,uid,res,context=context)
|
||||||
|
except Exception, e:
|
||||||
|
raise osv.except_osv(_('Error!'),_('%s' % (e)))
|
||||||
|
|
||||||
|
return {}
|
||||||
|
google_login()
|
||||||
|
|
||||||
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -0,0 +1,38 @@
|
||||||
|
<?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="Import Google Contacts">
|
||||||
|
<group colspan="4" col="4">
|
||||||
|
<field name="user"/>
|
||||||
|
<newline/>
|
||||||
|
<label string="ex: user@gmail.com" align="1.0" colspan="2"/>
|
||||||
|
<newline/>
|
||||||
|
<field name="password" password="True"/>
|
||||||
|
</group>
|
||||||
|
<separator string="" colspan="4"/>
|
||||||
|
<group colspan="2" col="2">
|
||||||
|
<button special="cancel" string="Cancel" icon="gtk-cancel"/>
|
||||||
|
<button name="check_login" string="Login" type="object" icon="terp-personal+"/>
|
||||||
|
</group>
|
||||||
|
</form>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record model="ir.actions.act_window" id="act_google_contact_import_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>
|
|
@ -27,6 +27,13 @@ from osv import fields,osv,orm
|
||||||
class res_partner_sync_base:
|
class res_partner_sync_base:
|
||||||
_inherit = "res.partner.address"
|
_inherit = "res.partner.address"
|
||||||
|
|
||||||
|
_columns = {
|
||||||
|
'sync_google':fields.boolean('Synchronize with Google', required=False),
|
||||||
|
}
|
||||||
|
_defaults = {
|
||||||
|
'sync_google':lambda *a:True
|
||||||
|
}
|
||||||
|
|
||||||
def create(self, cr, uid, vals, context=None):
|
def create(self, cr, uid, vals, context=None):
|
||||||
id = super(res_partner_sync_base, self).create(cr, uid, vals, context=context)
|
id = super(res_partner_sync_base, self).create(cr, uid, vals, context=context)
|
||||||
return id
|
return id
|
||||||
|
|
|
@ -36,7 +36,7 @@ class google_lib(object):
|
||||||
self.contact = gdata.contacts.service.ContactsService()
|
self.contact = gdata.contacts.service.ContactsService()
|
||||||
self.contact.email = email
|
self.contact.email = email
|
||||||
self.contact.password = password
|
self.contact.password = password
|
||||||
self.contact.source = 'GoogleInc-ContactsPythonSample-1'
|
self.contact.source = 'OpenERP'
|
||||||
try:
|
try:
|
||||||
self.contact.ProgrammaticLogin()
|
self.contact.ProgrammaticLogin()
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
|
|
|
@ -39,6 +39,8 @@ class google_contact_import(osv.osv_memory):
|
||||||
user_obj=self.pool.get('res.users').browse(cr, uid, uid)
|
user_obj=self.pool.get('res.users').browse(cr, uid, uid)
|
||||||
gmail_user=user_obj.gmail_user
|
gmail_user=user_obj.gmail_user
|
||||||
gamil_pwd=user_obj.gmail_password
|
gamil_pwd=user_obj.gmail_password
|
||||||
|
if not gmail_user or not gamil_pwd:
|
||||||
|
raise osv.except_osv(_('Error'), _("Please specify the user and password !"))
|
||||||
for obj in self.browse(cr, uid, ids, context=context):
|
for obj in self.browse(cr, uid, ids, context=context):
|
||||||
google_obj = sync_google_contact.google_lib(gmail_user, gamil_pwd)
|
google_obj = sync_google_contact.google_lib(gmail_user, gamil_pwd)
|
||||||
contact = google_obj._get_contact()
|
contact = google_obj._get_contact()
|
||||||
|
|
Loading…
Reference in New Issue