summaryrefslogtreecommitdiff
path: root/bin/addons/base/module/wizard
diff options
context:
space:
mode:
authorksa (Open ERP) <ksa@tinyerp.co.in>2010-08-26 18:05:54 +0530
committerksa (Open ERP) <ksa@tinyerp.co.in>2010-08-26 18:05:54 +0530
commit086e88d4ce2494d8f242599db13a59418bec091b (patch)
tree3263306437199c5a469d6a92907acb071b86ef25 /bin/addons/base/module/wizard
parentf917fe27b07a4e95b6bc4d02b9308f0dd34bfbe9 (diff)
[IMP]: convert old wizard into osv memory wizard for update module
bzr revid: ksa@tinyerp.co.in-20100826123554-2zd5yvp33slx8xfm
Diffstat (limited to 'bin/addons/base/module/wizard')
-rw-r--r--bin/addons/base/module/wizard/__init__.py3
-rw-r--r--bin/addons/base/module/wizard/base_module_import.py51
-rw-r--r--bin/addons/base/module/wizard/base_module_import_view.xml28
-rw-r--r--bin/addons/base/module/wizard/base_module_update.py108
-rw-r--r--bin/addons/base/module/wizard/base_module_update_view.xml68
-rw-r--r--bin/addons/base/module/wizard/wizard_update_module.py96
6 files changed, 254 insertions, 100 deletions
diff --git a/bin/addons/base/module/wizard/__init__.py b/bin/addons/base/module/wizard/__init__.py
index 69215e90c8c..c6b34de2936 100644
--- a/bin/addons/base/module/wizard/__init__.py
+++ b/bin/addons/base/module/wizard/__init__.py
@@ -19,7 +19,7 @@
#
##############################################################################
-import wizard_update_module
+import wizard_update_module # base_module_update
import wizard_module_upgrade
import wizard_configuration
import wizard_module_lang_install
@@ -29,6 +29,7 @@ import wizard_import_lang
import wizard_update_translations
import base_module_import
+import base_module_update
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/bin/addons/base/module/wizard/base_module_import.py b/bin/addons/base/module/wizard/base_module_import.py
index fc28452c6dd..cd916482279 100644
--- a/bin/addons/base/module/wizard/base_module_import.py
+++ b/bin/addons/base/module/wizard/base_module_import.py
@@ -40,6 +40,55 @@ class base_module_import(osv.osv_memory):
'module_file': fields.binary('Module .ZIP file', required=True),
}
+ def importzip(self, cr, uid, ids, context):
+ module_obj= self.pool.get('ir.module.module')
+ active_ids = context and context.get('active_ids', False)
+ data = self.browse(cr, uid, ids , context=context)[0]
+ module_data = data.module_file
+
+ val =base64.decodestring(module_data)
+ fp = StringIO()
+ fp.write(val)
+ fdata = zipfile.ZipFile(fp, 'r')
+ fname = fdata.namelist()[0]
+ module_name = os.path.split(fname)[0]
+
+ ad = tools.config['addons_path']
+
+ fname = os.path.join(ad,module_name+'.zip')
+ try:
+ fp = file(fname, 'wb')
+ fp.write(val)
+ fp.close()
+ except IOError, e:
+ raise osv.except_osv(_('Error !'), _('Can not create the module file: %s !') % (fname,) )
+
+ module_obj.update_list(cr, uid,{'module_name': module_name,})
+ data_obj = self.pool.get('ir.model.data')
+ id2 = data_obj._get_id(cr, uid, 'base', 'view_base_module_import_msg')
+ if id2:
+ id2 = data_obj.browse(cr, uid, id2, context=context).res_id
+
+ module_name = module_obj.browse(cr, uid, ids, context=context)
+ return {
+ 'domain': str([('name', '=', module_name)]),
+ 'name': 'Message',
+ 'view_type': 'form',
+ 'view_mode': 'form',
+ 'res_model': 'base.module.import.msg',
+ 'views': [(id2, 'form')],
+ 'view_id': False,
+ 'type': 'ir.actions.act_window',
+ 'target': 'new',
+ }
+
+base_module_import()
+
+class base_module_import_msg(osv.osv_memory):
+ """ message """
+ _name = "base.module.import.msg"
+ _description = "Message"
+
def action_module_open(self, cr, uid, ids, context):
module_obj = self.pool.get('base.module.import')
data = module_obj.browse(cr, uid, ids , context=context)[0]
@@ -61,5 +110,5 @@ class base_module_import(osv.osv_memory):
'type': 'ir.actions.act_window',
}
-base_module_import()
+base_module_import_msg() \ No newline at end of file
diff --git a/bin/addons/base/module/wizard/base_module_import_view.xml b/bin/addons/base/module/wizard/base_module_import_view.xml
index 818a7317c61..f46c7ebf293 100644
--- a/bin/addons/base/module/wizard/base_module_import_view.xml
+++ b/bin/addons/base/module/wizard/base_module_import_view.xml
@@ -15,7 +15,7 @@
<newline/>
<group colspan="6" >
<button special="cancel" string="Close" icon="gtk-cancel"/>
- <button name="action_module_open" string="Import module" type="object" icon="gtk-ok"/>
+ <button name="importzip" string="Import module" type="object" icon="gtk-ok"/>
</group>
</form>
</field>
@@ -37,6 +37,30 @@
parent="menu_management"
sequence="1"/>
+ <record id="view_base_module_import_msg" model="ir.ui.view">
+ <field name="name">Module Import Message</field>
+ <field name="model">base.module.import.msg</field>
+ <field name="type">form</field>
+ <field name="arch" type="xml">
+ <form string="Message">
+ <label string="Module successfully imported !"/>
+ <separator string="" colspan="4"/>
+ <newline/>
+ <group>
+ <button name="action_module_open" string="Close" type="object" icon="gtk-cancel"/>
+ </group>
+ </form>
+ </field>
+ </record>
+ <record id="action_view_base_module_import_msg" model="ir.actions.act_window">
+ <field name="name">Module Import Message</field>
+ <field name="res_model">base.module.import.msg</field>
+ <field name="view_type">form</field>
+ <field name="view_mode">form</field>
+ <field name="view_id" ref="view_base_module_import"/>
+ <field name="target">new</field>
+ </record>
</data>
-</openerp> \ No newline at end of file
+</openerp>
+
diff --git a/bin/addons/base/module/wizard/base_module_update.py b/bin/addons/base/module/wizard/base_module_update.py
new file mode 100644
index 00000000000..e6ad24cbbdf
--- /dev/null
+++ b/bin/addons/base/module/wizard/base_module_update.py
@@ -0,0 +1,108 @@
+# -*- 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 netsvc
+import pooler
+from osv import osv, fields
+
+class base_module_update(osv.osv_memory):
+ """ Update Module """
+
+ _name = "base.module.update"
+ _description = "Update Module"
+
+ def update_module(self, cr, uid, ids, context):
+ """
+ Update Module
+
+ @param cr: the current row, from the database cursor.
+ @param uid: the current user’s ID for security checks.
+ @param ids: the ID or list of IDs
+ @param context: A standard dictionary
+ """
+ data_obj = self.pool.get('ir.model.data')
+ id2 = data_obj._get_id(cr, uid, 'base', 'view_base_module_update_open')
+ if id2:
+ id2 = data_obj.browse(cr, uid, id2, context=context).res_id
+
+ return {
+ 'view_type': 'form',
+ 'view_mode': 'form',
+ 'res_model': 'base.module.update.open',
+ 'views': [(id2, 'form')],
+ 'view_id': False,
+ 'type': 'ir.actions.act_window',
+ 'target': 'new',
+
+ }
+
+base_module_update()
+
+class base_module_update_open(osv.osv_memory):
+ """ Update Module Open """
+
+ _name = "base.module.update.open"
+ _description = "Update Module Open"
+
+ def default_get(self, cr, uid, fields, context=None):
+ """
+ This function gets default values
+ @param self: The object pointer
+ @param cr: the current row, from the database cursor,
+ @param uid: the current user’s ID for security checks,
+ @param fields: List of fields for default value
+ @param context: A standard dictionary for contextual values
+ @return : default values of fields.
+ """
+
+ module_obj = self.pool.get('ir.module.module')
+ update, add = module_obj.update_list(cr, uid,)
+ return {'update': update, 'add': add}
+
+ _columns = {
+ 'update': fields.integer('Number of modules updated', readonly=True),
+ 'add': fields.integer('Number of modules added', readonly=True),
+ }
+
+ def action_module_open(self, cr, uid, ids, context):
+ """
+ Update Module List Open
+
+ @param cr: the current row, from the database cursor.
+ @param uid: the current user’s ID for security checks.
+ @param ids: the ID or list of IDs
+ @param context: A standard dictionary
+ """
+ res = {
+ 'domain': str([]),
+ 'name': 'Module List',
+ 'view_type': 'form',
+ 'view_mode': 'tree,form',
+ 'res_model': 'ir.module.module',
+ 'view_id': False,
+ 'type': 'ir.actions.act_window',
+ }
+ view_obj = self.pool.get('ir.ui.view')
+ search_view_id = view_obj.search(cr, uid, [('name','=','ir.module.module.list.select')], context=context)
+ if search_view_id:
+ res.update({'search_view_id' : search_view_id[0]})
+ return res
+
+base_module_update_open() \ No newline at end of file
diff --git a/bin/addons/base/module/wizard/base_module_update_view.xml b/bin/addons/base/module/wizard/base_module_update_view.xml
new file mode 100644
index 00000000000..5dad4bbd037
--- /dev/null
+++ b/bin/addons/base/module/wizard/base_module_update_view.xml
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+ <data>
+
+ <record id="view_base_module_update" model="ir.ui.view">
+ <field name="name">Module Update</field>
+ <field name="model">base.module.update</field>
+ <field name="type">form</field>
+ <field name="arch" type="xml">
+ <form string="Scan for new modules">
+ <label string="This function will check for new modules in the 'addons' path" colspan="4" align="0.0"/>
+ <separator string="" colspan="4" />
+ <newline/>
+ <group colspan="6" >
+ <button special="cancel" string="Close" icon="gtk-cancel"/>
+ <button name="update_module" string="Check new modules" type="object" icon="gtk-ok"/>
+ </group>
+ </form>
+ </field>
+ </record>
+
+ <record id="action_view_base_module_update" model="ir.actions.act_window">
+ <field name="name">Module Update</field>
+ <field name="type">ir.actions.act_window</field>
+ <field name="res_model">base.module.update</field>
+ <field name="view_type">form</field>
+ <field name="view_mode">form</field>
+ <field name="target">new</field>
+ </record>
+
+ <menuitem
+ name=" Update Modules List1111"
+ action="action_view_base_module_update"
+ id="menu_view_base_module_update"
+ parent="menu_management"
+ sequence="2"
+ icon="STOCK_CONVERT"/>
+
+ <record id="view_base_module_update_open" model="ir.ui.view">
+ <field name="name">Update ModuleList</field>
+ <field name="model">base.module.update.open</field>
+ <field name="type">form</field>
+ <field name="arch" type="xml">
+ <form string="New modules">
+ <field name="update" colspan="4"/>
+ <field name="add" colspan="4"/>
+ <separator string="" colspan="4" />
+ <newline/>
+ <group colspan="6" >
+ <button special="cancel" string="Close" icon="gtk-cancel"/>
+ <button name="action_module_open" string="OK" type="object" icon="gtk-ok"/>
+ </group>
+ </form>
+ </field>
+ </record>
+
+ <record id="action_view_base_module_update_open" model="ir.actions.act_window">
+ <field name="name">Update ModuleList</field>
+ <field name="type">ir.actions.act_window</field>
+ <field name="res_model">base.module.update.open</field>
+ <field name="view_type">form</field>
+ <field name="view_mode">form</field>
+ <field name="view_id" ref="view_base_module_update"/>
+ <field name="target">new</field>
+ </record>
+
+ </data>
+</openerp> \ No newline at end of file
diff --git a/bin/addons/base/module/wizard/wizard_update_module.py b/bin/addons/base/module/wizard/wizard_update_module.py
deleted file mode 100644
index 22e52bb6d6d..00000000000
--- a/bin/addons/base/module/wizard/wizard_update_module.py
+++ /dev/null
@@ -1,96 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2009 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 wizard
-import netsvc
-import pooler
-
-class wizard_update_module(wizard.interface):
-
- arch = '''<?xml version="1.0"?>
- <form string="Scan for new modules">
- <label string="This function will check for new modules in the 'addons' path" colspan="4" align="0.0"/>
-
- </form>'''
- fields = {
-
- }
-
- arch_module = '''<?xml version="1.0"?>
- <form string="New modules">
- <field name="update" colspan="4"/>
- <field name="add" colspan="4"/>
- </form>'''
-
- fields_module = {
- 'update': {'type': 'integer', 'string': 'Number of modules updated', 'readonly': True},
- 'add': {'type': 'integer', 'string': 'Number of modules added', 'readonly': True},
- }
-
- def _update_module(self, cr, uid, data, context):
- update, add = pooler.get_pool(cr.dbname).get('ir.module.module').update_list(cr, uid)
- return {'update': update, 'add': add}
-
- def _action_module_open(self, cr, uid, data, context):
-
- res = {
- 'domain': str([]),
- 'name': 'Module List',
- 'view_type': 'form',
- 'view_mode': 'tree,form',
- 'res_model': 'ir.module.module',
- 'view_id': False,
- 'type': 'ir.actions.act_window'
- }
-
- search_view_id = pooler.get_pool(cr.dbname).get('ir.ui.view').search(cr, uid, [('name','=','ir.module.module.list.select')], context=context)
- if search_view_id:
- res.update({'search_view_id' : search_view_id[0]})
- return res
-
- states = {
- 'init': {
- 'actions': [],
- 'result': {'type': 'form', 'arch': arch, 'fields': fields,
- 'state': [
- ('end', 'Cancel', 'gtk-cancel'),
- ('update', 'Check new modules', 'gtk-ok', True)
- ]
- }
- },
- 'update': {
- 'actions': [_update_module],
- 'result': {'type': 'form', 'arch': arch_module, 'fields': fields_module,
- 'state': [
- ('open_window', 'Ok', 'gtk-ok', True)
- ]
- }
- },
- 'open_window': {
- 'actions': [],
- 'result': {'type': 'action', 'action': _action_module_open, 'state':'end'}
- }
- }
-wizard_update_module('module.module.update')
-
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-