Forgot to add files

bzr revid: fp@tinyerp.com-d7a50fa5e9d66021b872136e9642ad92a676c949
This commit is contained in:
Fabien Pinckaers 2008-06-20 10:57:02 +00:00
parent c61376b843
commit 32c2328b80
3 changed files with 123 additions and 0 deletions

View File

@ -0,0 +1 @@
import wizard_menu

View File

@ -0,0 +1,84 @@
##############################################################################
#
# Copyright (c) 2004-2008 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from osv import fields,osv
class wizard_model_menu(osv.osv_memory):
_name = 'wizard.ir.model.menu.create'
_columns = {
'model_id': fields.many2one('ir.model','Model', required=True),
'menu_id': fields.many2one('ir.ui.menu', 'Parent Menu', required=True),
'name': fields.char('Menu Name', size=64, required=True),
'view_ids': fields.one2many('wizard.ir.model.menu.create.line', 'wizard_id', 'Views'),
}
_defaults = {
'model_id': lambda self,cr,uid,ctx: ctx.get('model_id', False)
}
def menu_create(self, cr, uid, ids, context={}):
for menu in self.browse(cr, uid, ids, context):
view_mode = []
views = []
for view in menu.view_ids:
view_mode.append(view.view_type)
views.append( (0,0,{
'view_id': view.view_id and view.view_id.id or False,
'view_mode': view.view_type,
'sequence': view.sequence
}))
val = {
'name': menu.name,
'res_model': menu.model_id.model,
'view_type': 'form',
'view_mode': ','.join(view_mode)
}
if views:
val['view_ids'] = views
else:
val['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'}
wizard_model_menu()
class wizard_model_menu_line(osv.osv_memory):
_name = 'wizard.ir.model.menu.create.line'
_columns = {
'wizard_id': fields.many2one('wizard.ir.model.menu.create','Wizard'),
'sequence': fields.integer('Sequence'),
'view_type': fields.selection([('tree','Tree'),('form','Form'),('graph','Graph'),('calendar','Calendar')],'View Type',required=True),
'view_id': fields.many2one('ir.ui.view', 'View'),
}
_defaults = {
'view_type': lambda self,cr,uid,ctx: 'tree'
}
wizard_model_menu_line()

View File

@ -0,0 +1,38 @@
<?xml version="1.0"?>
<terp>
<data>
<record model="ir.ui.view" id="view_model_menu_create">
<field name="name">Create Menu</field>
<field name="model">wizard.ir.model.menu.create</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Create Menu">
<field name="name"/>
<field name="menu_id"/>
<field name="model_id"/>
<newline/>
<field name="view_ids" colspan="4">
<tree string="Views" editable="bottom">
<field name="sequence"/>
<field name="view_type"/>
<field name="view_id"/>
</tree>
</field>
<label string="" colspan="2"/>
<group col="2" colspan="2">
<button string="Cancel" special="cancel"/>
<button string="Create Menu" name="menu_create" type="object"/>
</group>
</form>
</field>
</record>
<act_window name="Create Menu"
context="{'model_id': active_id}"
res_model="wizard.ir.model.menu.create"
view_mode="form"
target="new"
id="act_menu_create"/>
</data>
</terp>