summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Dony <odo@openerp.com>2012-10-03 16:20:06 +0200
committerOlivier Dony <odo@openerp.com>2012-10-03 16:20:06 +0200
commit1a541b2b69b4bbcf02b9cc664fc3ce6fe322dcb0 (patch)
tree9c0833d17fe5420e70cd2405ae3182cd99375c31
parenta42baec4553dd026ce11e04ef5a2efeb69f475d6 (diff)
[REV] Revert removal of ir.wizard.menu, still useful to create menuitems for custom models
bzr revid: odo@openerp.com-20121003142006-t1soc5xprdbcvice
-rw-r--r--openerp/addons/base/__openerp__.py1
-rw-r--r--openerp/addons/base/ir/__init__.py1
-rw-r--r--openerp/addons/base/ir/wizard/__init__.py23
-rw-r--r--openerp/addons/base/ir/wizard/wizard_menu.py53
-rw-r--r--openerp/addons/base/ir/wizard/wizard_menu_view.xml23
5 files changed, 101 insertions, 0 deletions
diff --git a/openerp/addons/base/__openerp__.py b/openerp/addons/base/__openerp__.py
index 173c6adcbc4..69552a61f72 100644
--- a/openerp/addons/base/__openerp__.py
+++ b/openerp/addons/base/__openerp__.py
@@ -42,6 +42,7 @@ The kernel of OpenERP, needed for all installation.
'res/res_security.xml',
'res/res_config.xml',
'data/res.country.state.csv',
+ 'ir/wizard/wizard_menu_view.xml',
'ir/ir.xml',
'ir/ir_translation_view.xml',
'ir/ir_filters.xml',
diff --git a/openerp/addons/base/ir/__init__.py b/openerp/addons/base/ir/__init__.py
index c296042e3b2..bc4f3eecfbf 100644
--- a/openerp/addons/base/ir/__init__.py
+++ b/openerp/addons/base/ir/__init__.py
@@ -36,6 +36,7 @@ import ir_translation
import ir_exports
import workflow
import ir_rule
+import wizard
import ir_config_parameter
import osv_memory_autovacuum
import ir_mail_server
diff --git a/openerp/addons/base/ir/wizard/__init__.py b/openerp/addons/base/ir/wizard/__init__.py
new file mode 100644
index 00000000000..23cc77e8c15
--- /dev/null
+++ b/openerp/addons/base/ir/wizard/__init__.py
@@ -0,0 +1,23 @@
+# -*- 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_menu
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+
diff --git a/openerp/addons/base/ir/wizard/wizard_menu.py b/openerp/addons/base/ir/wizard/wizard_menu.py
new file mode 100644
index 00000000000..17f0fc13f1d
--- /dev/null
+++ b/openerp/addons/base/ir/wizard/wizard_menu.py
@@ -0,0 +1,53 @@
+# -*- 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/>.
+#
+##############################################################################
+from osv import fields,osv
+
+class wizard_model_menu(osv.osv_memory):
+ _name = 'wizard.ir.model.menu.create'
+ _columns = {
+ 'menu_id': fields.many2one('ir.ui.menu', 'Parent Menu', required=True),
+ 'name': fields.char('Menu Name', size=64, required=True),
+ }
+
+ def menu_create(self, cr, uid, ids, context=None):
+ if not context:
+ context = {}
+ model_pool = self.pool.get('ir.model')
+ for menu in self.browse(cr, uid, ids, context):
+ model = model_pool.browse(cr, uid, context.get('model_id'), context=context)
+ val = {
+ 'name': menu.name,
+ 'res_model': model.model,
+ 'view_type': 'form',
+ 'view_mode': 'tree,form'
+ }
+ action_id = self.pool.get('ir.actions.act_window').create(cr, uid, val)
+ self.pool.get('ir.ui.menu').create(cr, uid, {
+ 'name': menu.name,
+ 'parent_id': menu.menu_id.id,
+ 'action': 'ir.actions.act_window,%d' % (action_id,),
+ 'icon': 'STOCK_INDENT'
+ }, context)
+ return {'type':'ir.actions.act_window_close'}
+
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+
diff --git a/openerp/addons/base/ir/wizard/wizard_menu_view.xml b/openerp/addons/base/ir/wizard/wizard_menu_view.xml
new file mode 100644
index 00000000000..7fd32b256e2
--- /dev/null
+++ b/openerp/addons/base/ir/wizard/wizard_menu_view.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+ <data>
+ <record id="view_model_menu_create" model="ir.ui.view">
+ <field name="name">Create Menu</field>
+ <field name="model">wizard.ir.model.menu.create</field>
+ <field name="arch" type="xml">
+ <form string="Create Menu" version="7.0">
+ <group>
+ <field name="name"/>
+ <field name="menu_id" domain="[('parent_id','&lt;&gt;',False)]"/>
+ </group>
+ <footer>
+ <button name="menu_create" string="Create _Menu" type="object" class="oe_highlight"/>
+ or
+ <button string="Cancel" class="oe_link" special="cancel" />
+ </footer>
+ </form>
+ </field>
+ </record>
+ <act_window context="{'model_id': active_id}" id="act_menu_create" name="Create Menu" res_model="wizard.ir.model.menu.create" target="new" view_mode="form"/>
+ </data>
+</openerp>