diff options
| author | Ujjvala Collins (OpenERP) <uco@tinyerp.com> | 2011-03-01 11:19:08 +0530 |
|---|---|---|
| committer | Ujjvala Collins (OpenERP) <uco@tinyerp.com> | 2011-03-01 11:19:08 +0530 |
| commit | e239f71d04497f1d0cb9de8728a2e6eeec2ee3ff (patch) | |
| tree | 3771c0d48dc7d8ce75724013df9d58084087a4c4 /addons | |
| parent | 05d002a0fa5c29f48fb32d458b23ee1c2d2f1ff9 (diff) | |
| parent | adfb0218850cb0d7df339bf580ab17e731d20aa6 (diff) | |
[MERGE]
bzr revid: uco@tinyerp.com-20110301054908-zzd1f3apatda2y8c
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/google_base_account/google_base_account.py | 4 | ||||
| -rw-r--r-- | addons/google_base_account/wizard/google_login.py | 4 | ||||
| -rw-r--r-- | addons/sync_base/__init__.py | 25 | ||||
| -rw-r--r-- | addons/sync_base/__openerp__.py | 40 | ||||
| -rw-r--r-- | addons/sync_base/wizard/__init__.py | 24 | ||||
| -rw-r--r-- | addons/sync_base/wizard/sync_base_view.xml | 40 | ||||
| -rw-r--r-- | addons/sync_base/wizard/synchronize_base.py | 61 | ||||
| -rw-r--r-- | addons/sync_google_contact/__openerp__.py | 4 | ||||
| -rw-r--r-- | addons/sync_google_contact/wizard/google_contact_import.py | 76 | ||||
| -rw-r--r-- | addons/sync_google_contact/wizard/google_contact_import_view.xml | 24 |
10 files changed, 42 insertions, 260 deletions
diff --git a/addons/google_base_account/google_base_account.py b/addons/google_base_account/google_base_account.py index c1642730e24..eef2a54f7fb 100644 --- a/addons/google_base_account/google_base_account.py +++ b/addons/google_base_account/google_base_account.py @@ -19,12 +19,12 @@ # ############################################################################## -from osv import fields,osv,orm +from osv import fields,osv class res_users(osv.osv): _inherit = "res.users" _columns = { - 'gmail_user': fields.char('User Name', size=64,), + 'gmail_user': fields.char('Google Account', size=64,), 'gmail_password': fields.char('Password', size=64), } res_users() diff --git a/addons/google_base_account/wizard/google_login.py b/addons/google_base_account/wizard/google_login.py index 8db6fa85258..d1ed3a1ed6d 100644 --- a/addons/google_base_account/wizard/google_login.py +++ b/addons/google_base_account/wizard/google_login.py @@ -30,7 +30,7 @@ class google_login(osv.osv_memory): _description ='Google Contact' _name = 'google.login' _columns = { - 'user': fields.char('User Name', size=64, required=True), + 'user': fields.char('Username', size=64, required=True), 'password': fields.char('Password', size=64), } @@ -74,7 +74,7 @@ class google_login(osv.osv_memory): } self.pool.get('res.users').write(cr, uid, uid, res, context=context) except : - raise osv.except_osv(_('Error'), _("Authication fail check the user and password !")) + raise osv.except_osv(_('Error'), _("Authentication fail check the user and password !")) return self._get_next_action(cr, uid, context=context) diff --git a/addons/sync_base/__init__.py b/addons/sync_base/__init__.py deleted file mode 100644 index 2bad42af76c..00000000000 --- a/addons/sync_base/__init__.py +++ /dev/null @@ -1,25 +0,0 @@ -# -*- 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 sync_base -import wizard -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: - diff --git a/addons/sync_base/__openerp__.py b/addons/sync_base/__openerp__.py deleted file mode 100644 index 9762267d1b1..00000000000 --- a/addons/sync_base/__openerp__.py +++ /dev/null @@ -1,40 +0,0 @@ -# -*- 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', - 'version': '1.0', - 'category': 'Generic Modules/Others', - 'description': """The module adds synchronization with multiple app """, - 'author': 'OpenERP SA', - 'website': 'http://www.openerp.com', - 'depends': ['base'], - 'init_xml': [], - 'update_xml': [ - 'wizard/sync_base_view.xml' - ], - 'demo_xml': [], - 'installable': True, - 'active': False, - 'certificate': '', -} -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/sync_base/wizard/__init__.py b/addons/sync_base/wizard/__init__.py deleted file mode 100644 index 70b742b7f79..00000000000 --- a/addons/sync_base/wizard/__init__.py +++ /dev/null @@ -1,24 +0,0 @@ -# -*- 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 synchronize_base - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/sync_base/wizard/sync_base_view.xml b/addons/sync_base/wizard/sync_base_view.xml deleted file mode 100644 index c957993fe67..00000000000 --- a/addons/sync_base/wizard/sync_base_view.xml +++ /dev/null @@ -1,40 +0,0 @@ -<?xml version="1.0"?> -<openerp> - <data> - <record model="ir.ui.view" id="sync_base_import_wizard_view"> - <field name="name">Synchronize contact</field> - <field name="model">synchronize.base.contact.wizard.import</field> - <field name="type">form</field> - <field name="arch" type="xml"> - <form string="Import contact from external adress book"> - <field name="tools"/> - <newline /> - <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="action_synchronize" string="_Synchronize" type="object" icon="terp-check"/> - </group> - </group> - </form> - </field> - </record> - - <record model="ir.actions.act_window" id="act_google_contact_import_form"> - <field name="name">Import contacts from remote address book</field> - <field name="type">ir.actions.act_window</field> - <field name="res_model">synchronize.base.contact.wizard.import</field> - <field name="view_type">form</field> - <field name="view_mode">form</field> - <field name="target">new</field> - <field name="view_id" ref="sync_base_import_wizard_view" /> - </record> - - - <menuitem name="Import contacts from remote address book" id="menu_sync_contact" - parent="base.menu_address_book" action="act_google_contact_import_form" - sequence="40" /> - - </data> -</openerp> diff --git a/addons/sync_base/wizard/synchronize_base.py b/addons/sync_base/wizard/synchronize_base.py deleted file mode 100644 index 9077b32398b..00000000000 --- a/addons/sync_base/wizard/synchronize_base.py +++ /dev/null @@ -1,61 +0,0 @@ -# -*- 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 _ - - -class synchronize_base(osv.osv_memory): - _description ='Synchronize base import contact ' - _name = "synchronize.base.contact.wizard.import" - - def _get_tools_name(self, cr, user, context): - """ - @return the list of value of the selection field - should be overwritten by subclasses - """ - return [] - - _columns = { - 'tools': fields.selection(_get_tools_name, 'App to synchronize with'), - } - - - def action_synchronize(self, cr, uid, ids, context=None): - wizard_data = self.browse(cr, uid, ids, context=context) - return self._get_action(cr, uid, wizard_data[0].tools, context=context) - - - def _get_action(self, cr, uid, tools, context=None): - if not tools: - raise osv.except_osv(_("Error !"),_("Select App to synchronize with.")) - return self._get_actions_dic(cr, uid, context=context)[tools] - - def _get_actions_dic(self, cr, uid, context=None): - """ - this method should be overwritten in specialize module - @return the dictonnaries of action - """ - return {'none' : {'type': 'ir.actions.act_window_close' }} - -synchronize_base() - -# 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 b40f787cdf8..481ad0a7c33 100644 --- a/addons/sync_google_contact/__openerp__.py +++ b/addons/sync_google_contact/__openerp__.py @@ -24,10 +24,10 @@ 'name': 'Google Contact', 'version': '1.0', 'category': 'Generic Modules/Others', - 'description': """The module adds google contact in partner address""", + 'description': """The module adds google contact in partner address""", 'author': 'OpenERP SA', 'website': 'http://www.openerp.com', - 'depends': ['base','google_base_account','sync_base'], + 'depends': ['base','google_base_account'], 'init_xml': [], 'update_xml': [ 'wizard/google_contact_import_view.xml' diff --git a/addons/sync_google_contact/wizard/google_contact_import.py b/addons/sync_google_contact/wizard/google_contact_import.py index b22c2460c1d..b8ae071a78d 100644 --- a/addons/sync_google_contact/wizard/google_contact_import.py +++ b/addons/sync_google_contact/wizard/google_contact_import.py @@ -30,53 +30,6 @@ try: 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_base_import(osv.osv_memory): - _inherit = 'synchronize.base.contact.wizard.import' - - def _get_tools_name(self, cr, user, context): - """ - @return the list of value of the selection field - should be overwritten by subclasses - """ - names = super(google_base_import, self)._get_tools_name(cr, user, context=context) - names.append(('gmail','Gmail address book')) - return names - - - _columns = { - 'tools': fields.selection(_get_tools_name, 'App to synchronize with'), - } - - - def _get_actions_dic(self, cr, uid, context=None): - """ - this method should be overwritten in specialize module - @return the dictonnaries of action - """ - actions = super(google_base_import, self)._get_actions_dic(cr, uid, context=context) - - data_obj = self.pool.get('ir.model.data') - data_id = data_obj._get_id(cr, uid, 'google_base_account', 'view_google_login_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': 'google.login.contact', - 'view_id': False, - 'context': context, - 'views': [(view_id, 'form')], - 'type': 'ir.actions.act_window', - 'target': 'new', - } - actions['gmail'] = value - return actions - -google_base_import() - class google_contact_import(osv.osv_memory): _inherit = 'google.login' _name = 'google.login.contact' @@ -120,12 +73,12 @@ class synchronize_google_contact(osv.osv_memory): return res _columns = { - 'create_partner': fields.boolean('Create Partner', help="It will create Partner for given gmail user otherwise only adds contacts in Partner Addresses.") , - 'group_name': fields.selection(_get_group, "Group Name", size=32,help="Choose which group to import, By defult it take all "), + 'create_partner': fields.selection([('create_all','Create partner for each contact'),('create_address','Import only address')],'Options'), + 'group_name': fields.selection(_get_group, "Group Name", size=32,help="Choose which group to import, By default it takes all."), } _defaults = { - 'create_partner': True, + 'create_partner': 'create_all', 'group_name': 'all', } @@ -138,7 +91,7 @@ class synchronize_google_contact(osv.osv_memory): return partner_id, data def import_contact(self, cr, uid, ids, context=None): - obj=self.browse(cr, uid, ids, context=context)[0] + obj = self.browse(cr, uid, ids, context=context)[0] if obj.group_name == 'none': return { 'type': 'ir.actions.act_window_close' } @@ -155,28 +108,27 @@ class synchronize_google_contact(osv.osv_memory): if obj.group_name not in ['all','none']: query = gdata.contacts.service.ContactsQuery() - query.group =obj.group_name + query.group = obj.group_name contact = gd_client.GetContactsFeed(query.ToUri()) else: contact = gd_client.GetContactsFeed() - ids = self.create_contact( cr, uid, gd_client,contact, partner_id=obj.create_partner,context=context) + ids = self.create_contact(cr, uid, gd_client, contact, option=obj.create_partner,context=context) if not ids: return {'type': 'ir.actions.act_window_close'} return { - 'name': _('Partner'), + 'name': _(obj.create_partner =='create_all' and 'Partner') or _('Contacts'), 'domain': "[('id','in', ["+','.join(map(str,ids))+"])]", 'view_type': 'form', 'view_mode': 'tree,form', - 'res_model': obj.create_partner and 'res.partner' or 'res.partner.address', + '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, gd_client,contact, partner_id=False,context=None): + def create_contact(self, cr, uid, gd_client, contact, option,context=None): model_obj = self.pool.get('ir.model.data') addresss_obj = self.pool.get('res.partner.address') addresses = [] @@ -227,7 +179,7 @@ class synchronize_google_contact(osv.osv_memory): #create or link to an existing partner only if it's a new contact res_id = addresss_obj.create(cr, uid, data, context=context) data['address_id'] = res_id - if partner_id: + if option == 'create_all': partner_id, data = self.create_partner(cr, uid, data, context=context) partner_ids.append(partner_id[0]) addresses.append(res_id) @@ -237,15 +189,15 @@ class synchronize_google_contact(osv.osv_memory): next = contact.GetNextLink() contact = next and gd_client.GetContactsFeed(next.href) or None - if partner_id: + if option == 'create_all': return partner_ids else: return addresses - def update_contact(self, cr, uid, contact_ids, data,context=None): + def update_contact(self, cr, uid, contact_ids, data, context=None): addresss_obj = self.pool.get('res.partner.address') - if context==None: - context={} + if context == None: + context = {} res = {} 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')) diff --git a/addons/sync_google_contact/wizard/google_contact_import_view.xml b/addons/sync_google_contact/wizard/google_contact_import_view.xml index 41e02dcb7a8..f43603ee8a2 100644 --- a/addons/sync_google_contact/wizard/google_contact_import_view.xml +++ b/addons/sync_google_contact/wizard/google_contact_import_view.xml @@ -9,8 +9,8 @@ <form string="Import Google Contacts"> <group colspan="4" col="4"> <field name="group_name" /> - <separator string="Do you want to create partner?" colspan="4"/> - <field name="create_partner" colspan="4"/> + <separator string="Import Options" colspan="4"/> + <field name="create_partner"/> </group> <separator string="" colspan="4"/> <group colspan="4" col="4"> @@ -23,5 +23,25 @@ </form> </field> </record> + + + <!-- + Login Action + --> + <record model="ir.actions.act_window" id="act_google_login_form"> + <field name="name">Import contacts from your google account</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="google_base_account.view_google_login_form" /> + </record> + + + <menuitem id="menu_sync_contact" + parent="base.menu_address_book" + action="act_google_login_form" + sequence="40" /> </data> </openerp> |
