[ADD]: Add Message wizard
authorAtul Patel (OpenERP) <atp@tinyerp.com>
Thu, 17 Feb 2011 08:36:34 +0000 (14:06 +0530)
committerAtul Patel (OpenERP) <atp@tinyerp.com>
Thu, 17 Feb 2011 08:36:34 +0000 (14:06 +0530)
bzr revid: atp@tinyerp.com-20110217083634-8aw5rz8q3pfz0rdo

addons/import_sugarcrm/import_sugarcrm.py
addons/import_sugarcrm/wizard/__init__.py [new file with mode: 0644]
addons/import_sugarcrm/wizard/import_message.py [new file with mode: 0644]
addons/import_sugarcrm/wizard/import_message_view.xml [new file with mode: 0644]
addons/import_sugarcrm/wizard/sugarcrm_login.py [new file with mode: 0644]
addons/import_sugarcrm/wizard/sugarcrm_login_view.xml [new file with mode: 0644]

index d99f0d9..9fd3977 100644 (file)
@@ -206,7 +206,7 @@ class import_sugarcrm(osv.osv):
             'views': [(resource_id,'form')],
             'type': 'ir.actions.act_window',
             'target': 'new',
-        }                    
+        }                 
 
 import_sugarcrm()
 
diff --git a/addons/import_sugarcrm/wizard/__init__.py b/addons/import_sugarcrm/wizard/__init__.py
new file mode 100644 (file)
index 0000000..09c13c3
--- /dev/null
@@ -0,0 +1,23 @@
+# -*- 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
diff --git a/addons/import_sugarcrm/wizard/import_message.py b/addons/import_sugarcrm/wizard/import_message.py
new file mode 100644 (file)
index 0000000..7c9f170
--- /dev/null
@@ -0,0 +1,29 @@
+# -*- 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()
diff --git a/addons/import_sugarcrm/wizard/import_message_view.xml b/addons/import_sugarcrm/wizard/import_message_view.xml
new file mode 100644 (file)
index 0000000..ac619ef
--- /dev/null
@@ -0,0 +1,21 @@
+<?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
diff --git a/addons/import_sugarcrm/wizard/sugarcrm_login.py b/addons/import_sugarcrm/wizard/sugarcrm_login.py
new file mode 100644 (file)
index 0000000..8a27770
--- /dev/null
@@ -0,0 +1,56 @@
+# -*- 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
diff --git a/addons/import_sugarcrm/wizard/sugarcrm_login_view.xml b/addons/import_sugarcrm/wizard/sugarcrm_login_view.xml
new file mode 100644 (file)
index 0000000..6aae5e2
--- /dev/null
@@ -0,0 +1,45 @@
+<?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>
+