diff options
| author | Meera Trambadia (OpenERP) <mtr@tinyerp.com> | 2011-09-16 11:11:38 +0530 |
|---|---|---|
| committer | Meera Trambadia (OpenERP) <mtr@tinyerp.com> | 2011-09-16 11:11:38 +0530 |
| commit | d979aad3de95ae24aa1db52cf17c4eecf3d3ce6b (patch) | |
| tree | 592698c8e0dab53fcd157dd456a800bd4a80b5bf /addons/google_base_account | |
| parent | eea80125f7d1c739260929fb1f38866ef21439e1 (diff) | |
| parent | d101d3fbaaffe2d0219ac6cfeef50338a2501664 (diff) | |
[MERGE] branch merged with lp:openobject-addons
bzr revid: mtr@tinyerp.com-20110916054138-93b3caomaij5dyp4
Diffstat (limited to 'addons/google_base_account')
| -rw-r--r-- | addons/google_base_account/__init__.py | 26 | ||||
| -rw-r--r-- | addons/google_base_account/__openerp__.py | 41 | ||||
| -rw-r--r-- | addons/google_base_account/google_base_account.py | 33 | ||||
| -rw-r--r-- | addons/google_base_account/google_base_account_view.xml | 20 | ||||
| -rw-r--r-- | addons/google_base_account/wizard/__init__.py | 25 | ||||
| -rw-r--r-- | addons/google_base_account/wizard/google_login.py | 84 | ||||
| -rw-r--r-- | addons/google_base_account/wizard/google_login_view.xml | 42 |
7 files changed, 271 insertions, 0 deletions
diff --git a/addons/google_base_account/__init__.py b/addons/google_base_account/__init__.py new file mode 100644 index 00000000000..e1a476431af --- /dev/null +++ b/addons/google_base_account/__init__.py @@ -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: + diff --git a/addons/google_base_account/__openerp__.py b/addons/google_base_account/__openerp__.py new file mode 100644 index 00000000000..409ca205c74 --- /dev/null +++ b/addons/google_base_account/__openerp__.py @@ -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: diff --git a/addons/google_base_account/google_base_account.py b/addons/google_base_account/google_base_account.py new file mode 100644 index 00000000000..c860ec84374 --- /dev/null +++ b/addons/google_base_account/google_base_account.py @@ -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: + diff --git a/addons/google_base_account/google_base_account_view.xml b/addons/google_base_account/google_base_account_view.xml new file mode 100644 index 00000000000..9296ba135c0 --- /dev/null +++ b/addons/google_base_account/google_base_account_view.xml @@ -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> diff --git a/addons/google_base_account/wizard/__init__.py b/addons/google_base_account/wizard/__init__.py new file mode 100644 index 00000000000..a6b9c644a1e --- /dev/null +++ b/addons/google_base_account/wizard/__init__.py @@ -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: + diff --git a/addons/google_base_account/wizard/google_login.py b/addons/google_base_account/wizard/google_login.py new file mode 100644 index 00000000000..78f27e51da4 --- /dev/null +++ b/addons/google_base_account/wizard/google_login.py @@ -0,0 +1,84 @@ +# -*- 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 + import gdata.contacts.client + import gdata.calendar.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='', context=None): + if type == 'group': + gd_client = gdata.contacts.client.ContactsClient(source='OpenERP') + if type == 'contact' : + gd_client = gdata.contacts.service.ContactsService() + if type == 'calendar': + gd_client = gdata.calendar.service.CalendarService() + else: + 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: diff --git a/addons/google_base_account/wizard/google_login_view.xml b/addons/google_base_account/wizard/google_login_view.xml new file mode 100644 index 00000000000..9c5c93c613e --- /dev/null +++ b/addons/google_base_account/wizard/google_login_view.xml @@ -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@gmail.com" 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> |
