'views': [(resource_id,'form')],
'type': 'ir.actions.act_window',
'target': 'new',
- }
+ }
import_sugarcrm()
--- /dev/null
+# -*- 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 sugarcrm_login
+import import_message
--- /dev/null
+# -*- 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 import_message(osv.osv):
+ """Import Message"""
+
+ _name = "import.message"
+ _description = __doc__
+
+import_message()
--- /dev/null
+<?xml version="1.0"?>
+<openerp>
+ <data>
+
+ <!-- Import Message Form View -->
+ <record model="ir.ui.view" id="view_import_message_form">
+ <field name="name">import.message.form</field>
+ <field name="model">import.message</field>
+ <field name="type">form</field>
+ <field name="arch" type="xml">
+ <form string="Import Message">
+ <label string="Import Data Successfully" colspan="4"/>
+ <separator string="" colspan="4" />
+ <label string="" colspan="2"/>
+ <button icon="gtk-ok" special="cancel" string="_Ok"/>
+ </form>
+ </field>
+ </record>
+
+ </data>
+</openerp>
\ No newline at end of file
--- /dev/null
+# -*- 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 _
+from import_sugarcrm import sugar
+
+class sugarcrm_login(osv.osv):
+ """SugarCRM Login"""
+
+ _name = "sugarcrm.login"
+ _description = __doc__
+ _columns = {
+ 'username': fields.char('User Name', size=64, required=True),
+ 'password': fields.char('Password', size=24,required=True),
+ }
+
+ def open_import(self, cr, uid, ids, context=None):
+
+ for current in self.browse(cr, uid, ids, context):
+ PortType,sessionid = sugar.login(current.username, current.password)
+ if sessionid == '-1':
+ raise osv.except_osv(_('Error !'), _('Wrong username and password'))
+
+ obj_model = self.pool.get('ir.model.data')
+ model_data_ids = obj_model.search(cr,uid,[('model','=','ir.ui.view'),('name','=','import.sugarcrm.form')])
+ resource_id = obj_model.read(cr, uid, model_data_ids, fields=['res_id'])
+ context.update({'rec_id': ids, 'username': current.username, 'password': current.password})
+ return {
+ 'view_type': 'form',
+ 'view_mode': 'form',
+ 'res_model': 'import.sugarcrm',
+ 'views': [(resource_id,'form')],
+ 'type': 'ir.actions.act_window',
+ 'target': 'new',
+ 'context': context
+ }
+
+sugarcrm_login()
\ No newline at end of file
--- /dev/null
+<?xml version="1.0"?>
+<openerp>
+ <data>
+
+ <!-- Sugarcrm Login Form View -->
+ <record model="ir.ui.view" id="view_sugarcrm_login_form">
+ <field name="name">sugarcrm.login.form</field>
+ <field name="model">sugarcrm.login</field>
+ <field name="type">form</field>
+ <field name="arch" type="xml">
+ <form string="Sugarcrm Login">
+ <group colspan="4" >
+ <separator string="Please enter your user name and password." colspan="4"/>
+ <field name="username"/>
+ <newline/>
+ <field name="password" password="True" />
+ </group>
+ <separator string="" colspan="4" />
+ <group colspan="4" >
+ <label string="" colspan="2"/>
+ <button icon="gtk-cancel" special="cancel" string="_Cancel"/>
+ <button name="open_import" string="Login"
+ type="object" icon="gtk-ok"/>
+ </group>
+ </form>
+ </field>
+ </record>
+
+ <!-- Sugarcrm Login Action -->
+
+ <record model="ir.actions.act_window" id="action_sugarcrm_login">
+ <field name="name">Sugarcrm Login</field>
+ <field name="res_model">sugarcrm.login</field>
+ <field name="view_type">form</field>
+ <field name="view_mode">tree,form</field>
+ <field name="view_id" ref="view_sugarcrm_login_form"/>
+ <field name="target">new</field>
+ </record>
+
+ <menuitem name="Sugarcrm" id="menu_sugarcrm" parent="base.menu_base_partner"/>
+ <menuitem name="Import Sugarcrm" id="menu_sugarcrm_login" parent="menu_sugarcrm" action="action_sugarcrm_login" icon="STOCK_EXECUTE"/>
+
+ </data>
+</openerp>
+