From 68217409ac6f17fb4c0a8e55ed340fc89d0fea89 Mon Sep 17 00:00:00 2001 From: "Atul Patel (OpenERP)" Date: Mon, 14 Feb 2011 12:33:50 +0530 Subject: [PATCH 001/614] [ADD]: Add Import_sugarcrm Module and Import SUgarcrm lead data into crm lead bzr revid: atp@tinyerp.com-20110214070350-t1493xf7bptv9o1y --- addons/import_sugarcrm/__init__.py | 22 + addons/import_sugarcrm/__openerp__.py | 37 + addons/import_sugarcrm/import_sugarcrm.py | 77 + .../import_sugarcrm/import_sugarcrm_view.xml | 43 + addons/import_sugarcrm/sugar.py | 100 ++ addons/import_sugarcrm/sugarsoap_services.py | 1372 +++++++++++++++++ .../sugarsoap_services_types.py | 642 ++++++++ 7 files changed, 2293 insertions(+) create mode 100644 addons/import_sugarcrm/__init__.py create mode 100644 addons/import_sugarcrm/__openerp__.py create mode 100644 addons/import_sugarcrm/import_sugarcrm.py create mode 100644 addons/import_sugarcrm/import_sugarcrm_view.xml create mode 100644 addons/import_sugarcrm/sugar.py create mode 100644 addons/import_sugarcrm/sugarsoap_services.py create mode 100644 addons/import_sugarcrm/sugarsoap_services_types.py diff --git a/addons/import_sugarcrm/__init__.py b/addons/import_sugarcrm/__init__.py new file mode 100644 index 00000000000..cff22e2ae9e --- /dev/null +++ b/addons/import_sugarcrm/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# +# 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 . +# +############################################################################## + +import import_sugarcrm diff --git a/addons/import_sugarcrm/__openerp__.py b/addons/import_sugarcrm/__openerp__.py new file mode 100644 index 00000000000..0ce2e65c1bb --- /dev/null +++ b/addons/import_sugarcrm/__openerp__.py @@ -0,0 +1,37 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# +# 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 . +# +############################################################################## + +{ + 'name': 'Import SugarCRM Data into OpenERP Module.', + 'version': '1.0', + 'category': 'Generic Modules', + 'description': """This Module Import SugarCRM "Leads", "Opportunity", "Accounts" and "contacts" Data into OpenERP Module.""", + 'author': 'OpenERP SA', + 'website': 'http://www.openerp.com', + 'depends': [], + 'init_xml': [], + 'update_xml': ["import_sugarcrm_view.xml"], + 'demo_xml': [], + 'test': [], + 'installable': True, + 'active': False, +} +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/import_sugarcrm/import_sugarcrm.py b/addons/import_sugarcrm/import_sugarcrm.py new file mode 100644 index 00000000000..2739708b4db --- /dev/null +++ b/addons/import_sugarcrm/import_sugarcrm.py @@ -0,0 +1,77 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# +# 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 . +# +############################################################################## + +from osv import fields, osv +import sugar +import tools +from tools.translate import _ + +class import_sugarcrm(osv.osv): + """Import SugarCRM DATA""" + + _name = "import.sugarcrm" + _description = __doc__ + _columns = { + 'mod_name':fields.selection([ + ('lead','Leads'), + ('opportunity','Opportunities'), + ('accounts','Accounts'), + ('contact','Contacts'), + ],'Module Name', help="Module Name is used to specify which Module data want to Import"), + } + + def import_data(self, cr, uid, ids,context=None): + if not context: + context={} + lead_pool = self.pool.get("crm.lead") + for current in self.browse(cr, uid, ids): + if current.mod_name == 'lead' or current.mod_name == 'opportunity': + module_name = 'crm' + + elif current.mod_name == "accounts": + module_name = 'account' + ids = self.pool.get("ir.module.module").search(cr, uid, [("name", '=', + module_name), ('state', '=', 'installed')]) + if not ids: + raise osv.except_osv(_('Error !'), _('Please Install %s Module') % (module_name)) + + if current.mod_name == 'lead': + sugar_name = "Leads" + elif current.mod_name == 'opportunity': + sugar_name="Opportunities" + elif current.mod_name == 'accounts': + sugar_name="Accounts" + elif current.mod_name == 'contact': + sugar_name="Contacts" + + sugar_data = sugar.test(sugar_name) + for sugar_val in sugar_data: + if sugar_name == "Leads": + lead_pool.create(cr, uid, {'name': sugar_val.get("first_name"), 'email_from': sugar_val.get("email1"), 'phone': sugar_val.get("phone_work"), 'mobile': sugar_val.get("phone_mobile"), 'write_date':sugar_val.get("date_modified"), 'user_id':sugar_val.get("created_by"), 'partner_name':sugar_val.get("title"), 'city':sugar_val.get("primary_address_city")}) + + return {} + +import_sugarcrm() + + + + + diff --git a/addons/import_sugarcrm/import_sugarcrm_view.xml b/addons/import_sugarcrm/import_sugarcrm_view.xml new file mode 100644 index 00000000000..80699e11f35 --- /dev/null +++ b/addons/import_sugarcrm/import_sugarcrm_view.xml @@ -0,0 +1,43 @@ + + + + + + + import.sugarcrm.form + import.sugarcrm + form + +
+ + + + + + +