[IMP]: board: Apply view_init method in board
bzr revid: ksa@tinyerp.co.in-20100318101829-gmbuio3nz4hinczt
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
@@ -15,7 +15,7 @@
|
||||
# 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/>.
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
@@ -26,19 +26,26 @@ class board_menu_create(osv.osv_memory):
|
||||
"""
|
||||
Create Menu
|
||||
"""
|
||||
def check_views(self, cr, uid, context):
|
||||
def view_init(self, cr, uid, fields, context=None):
|
||||
"""
|
||||
This function checks for precondition before wizard executes
|
||||
@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
|
||||
|
||||
check dashboard view on menu name field.
|
||||
@return: False
|
||||
@return: False
|
||||
"""
|
||||
data = context and context.get('active_id', False) or False
|
||||
if data:
|
||||
board = self.pool.get('board.board').browse(cr, uid, data)
|
||||
if not board.line_ids:
|
||||
raise osv.except_osv(_('User Error!'),
|
||||
_('Please Insert Dashboard View(s) !'))
|
||||
raise osv.except_osv(_('User Error!'),
|
||||
_('Please Insert Dashboard View(s) !'))
|
||||
return False
|
||||
|
||||
|
||||
def board_menu_create(self, cr, uid, ids, context=None):
|
||||
"""
|
||||
Create Menu.
|
||||
@@ -49,7 +56,7 @@ class board_menu_create(osv.osv_memory):
|
||||
"""
|
||||
if not context:
|
||||
context = {}
|
||||
|
||||
|
||||
context_id = context and context.get('active_id', False) or False
|
||||
if context_id:
|
||||
board = self.pool.get('board.board').browse(cr, uid, context_id)
|
||||
@@ -60,8 +67,8 @@ class board_menu_create(osv.osv_memory):
|
||||
'res_model': 'board.board',
|
||||
'view_id': board.view_id.id,
|
||||
})
|
||||
obj_menu = self.pool.get('ir.ui.menu')
|
||||
#start Loop
|
||||
obj_menu = self.pool.get('ir.ui.menu')
|
||||
#start Loop
|
||||
for data in self.read(cr, uid, ids):
|
||||
obj_menu.create(cr, uid, {
|
||||
'name': data.get('menu_name'),
|
||||
@@ -71,16 +78,14 @@ class board_menu_create(osv.osv_memory):
|
||||
}, context=context)
|
||||
#End Loop
|
||||
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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user