[IMP]: board: Converted wizards to osv_memory wizards
bzr revid: atp@tinyerp.co.in-20100315135305-ifo07chq160w6weg
This commit is contained in:
@@ -27,7 +27,7 @@
|
||||
'description': """Base module for all dashboards.""",
|
||||
'author': 'Tiny',
|
||||
'depends': ['base'],
|
||||
'update_xml': ['security/ir.model.access.csv', 'board_view.xml'],
|
||||
'update_xml': ['security/ir.model.access.csv', 'wizard/board_menu_create_view.xml', 'board_view.xml'],
|
||||
'demo_xml': [],
|
||||
'installable': True,
|
||||
'active': False,
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
<field name="view_mode">form,tree</field>
|
||||
</record>
|
||||
|
||||
<wizard id="wizard_board_create_menu" model="board.board" multi="True" name="board.board.menu.create" string="Create Board Menu" />
|
||||
<!-- <wizard id="wizard_board_create_menu" model="board.board" multi="True" name="board.board.menu.create" string="Create Board Menu" /> -->
|
||||
|
||||
<record id="view_board_tree" model="ir.ui.view">
|
||||
<field name="name">board.board.tree</field>
|
||||
@@ -54,7 +54,7 @@
|
||||
<field name="arch" type="xml">
|
||||
<form string="Dashboard">
|
||||
<field name="name" select="1"/>
|
||||
<button colspan="2" name="%(wizard_board_create_menu)d" string="Create Menu" type="action" icon="gtk-justify-fill"/>
|
||||
<button colspan="2" name="%(action_board_menu_create)d" string="Create Menu" type="action" icon="gtk-justify-fill"/>
|
||||
<field colspan="4" name="line_ids">
|
||||
<tree string="Dashboard View">
|
||||
<field name="name"/>
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import board_wizard
|
||||
import board_menu_create
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
# -*- 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 _
|
||||
|
||||
class board_menu_create(osv.osv_memory):
|
||||
"""
|
||||
Create Menu
|
||||
"""
|
||||
def check_views(self, cr, uid, context):
|
||||
board = self.pool.get('board.board').browse(cr, uid, context['active_id'])
|
||||
if not board.line_ids:
|
||||
raise osv.except_osv(_('User Error!'), _('Please Insert Dashboard View(s) !'))
|
||||
return False
|
||||
|
||||
def board_menu_create(self, cr, uid, ids, context):
|
||||
"""
|
||||
Create Menu.
|
||||
@param cr: the current row, from the database cursor,
|
||||
@param uid: the current user’s ID for security checks,
|
||||
@param ids: List of Board Menu Create's IDs
|
||||
@return : Dictionary {}.
|
||||
"""
|
||||
board = self.pool.get('board.board').browse(cr, uid, context['active_id'])
|
||||
action_id = self.pool.get('ir.actions.act_window').create(cr, uid, {
|
||||
'name': board.name,
|
||||
'view_type':'form',
|
||||
'view_mode':'form',
|
||||
'res_model': 'board.board',
|
||||
'view_id': board.view_id.id,
|
||||
})
|
||||
for data in self.read(cr, uid, ids):
|
||||
self.pool.get('ir.ui.menu').create(cr, uid, {
|
||||
'name': data['menu_name'],
|
||||
'parent_id': data['menu_parent_id'],
|
||||
'icon': 'STOCK_SELECT_COLOR',
|
||||
'action': 'ir.actions.act_window,'+str(action_id)
|
||||
}, context)
|
||||
|
||||
return {}
|
||||
|
||||
_name = "board.menu.create"
|
||||
_description = "Menu Create"
|
||||
_columns = {
|
||||
'menu_name':fields.char('Menu Name', size=64, required=True),
|
||||
'menu_parent_id':fields.many2one('ir.ui.menu', 'Parent Menu', required=True),
|
||||
}
|
||||
_defaults = {
|
||||
'menu_name':check_views,
|
||||
}
|
||||
|
||||
board_menu_create()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<record id="view_board_menu_create" model="ir.ui.view">
|
||||
<field name="name">board.menu.create.form</field>
|
||||
<field name="model">board.menu.create</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Create Menu For Dashboard">
|
||||
<group colspan="4" >
|
||||
<separator string="Menu Information" colspan="4"/>
|
||||
<field name="menu_name"/>
|
||||
<field name="menu_parent_id"/>
|
||||
</group>
|
||||
<separator string="" colspan="4" />
|
||||
<group colspan="4" col="6">
|
||||
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
|
||||
<button icon="gtk-save" string="Create Menu" name="board_menu_create" type="object"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_board_menu_create" model="ir.actions.act_window">
|
||||
<field name="name">Create Board Menu</field>
|
||||
<field name="res_model">board.menu.create</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="view_id" ref="view_board_menu_create"/>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
@@ -1,86 +0,0 @@
|
||||
# -*- 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 time
|
||||
import wizard
|
||||
import osv
|
||||
import pooler
|
||||
from tools.translate import _
|
||||
|
||||
section_form = '''<?xml version="1.0"?>
|
||||
<form string="Create Menu For Dashboard">
|
||||
<separator string="Menu Information" colspan="4"/>
|
||||
<field name="menu_name"/>
|
||||
<field name="menu_parent_id"/>
|
||||
</form>'''
|
||||
|
||||
section_fields = {
|
||||
'menu_name': {'string':'Menu Name', 'type':'char', 'required':True, 'size':64},
|
||||
'menu_parent_id': {'string':'Parent Menu', 'type':'many2one', 'relation':'ir.ui.menu', 'required':True},
|
||||
}
|
||||
|
||||
def check_views(self, cr, uid, data, context):
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
board = pool.get('board.board').browse(cr, uid, data['id'])
|
||||
if not board.line_ids:
|
||||
raise wizard.except_wizard(_('User Error!'),_('Please Insert Dashboard View(s) !'))
|
||||
return data['form']
|
||||
|
||||
def board_menu_create(self, cr, uid, data, context):
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
board = pool.get('board.board').browse(cr, uid, data['id'])
|
||||
|
||||
action_id = pool.get('ir.actions.act_window').create(cr, uid, {
|
||||
'name': board.name,
|
||||
'view_type':'form',
|
||||
'view_mode':'form',
|
||||
'res_model': 'board.board',
|
||||
'view_id': board.view_id.id,
|
||||
})
|
||||
pool.get('ir.ui.menu').create(cr, uid, {
|
||||
'name': data['form']['menu_name'],
|
||||
'parent_id': data['form']['menu_parent_id'],
|
||||
'icon': 'STOCK_SELECT_COLOR',
|
||||
'action': 'ir.actions.act_window,'+str(action_id)
|
||||
}, context)
|
||||
|
||||
return {}
|
||||
|
||||
class wizard_section_menu_create(wizard.interface):
|
||||
states = {
|
||||
'init': {
|
||||
'actions': [check_views],
|
||||
'result': {'type':'form', 'arch':section_form, 'fields':section_fields, 'state':[('end','Cancel'),('create_menu','Create Menu')]}
|
||||
},
|
||||
'create_menu': {
|
||||
'actions': [board_menu_create],
|
||||
'result': {
|
||||
'type':'state',
|
||||
'state':'end'
|
||||
}
|
||||
}
|
||||
}
|
||||
wizard_section_menu_create('board.board.menu.create')
|
||||
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
Reference in New Issue
Block a user