[REV] Revert removal of ir.wizard.menu, still useful to create menuitems for custom models
bzr revid: odo@openerp.com-20121003142006-t1soc5xprdbcvice
This commit is contained in:
@@ -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',
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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','<>',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>
|
||||
Reference in New Issue
Block a user