2010-03-15 13:53:05 +00:00
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
##############################################################################
|
2010-03-18 10:18:29 +00:00
|
|
|
|
#
|
2010-03-15 13:53:05 +00:00
|
|
|
|
# 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
|
2010-03-18 10:18:29 +00:00
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2010-03-15 13:53:05 +00:00
|
|
|
|
#
|
|
|
|
|
##############################################################################
|
|
|
|
|
|
|
|
|
|
from osv import fields, osv
|
|
|
|
|
from tools.translate import _
|
|
|
|
|
|
|
|
|
|
class board_menu_create(osv.osv_memory):
|
|
|
|
|
"""
|
|
|
|
|
Create Menu
|
|
|
|
|
"""
|
2010-03-18 10:18:29 +00:00
|
|
|
|
def view_init(self, cr, uid, fields, context=None):
|
2010-03-17 10:22:07 +00:00
|
|
|
|
"""
|
2010-03-18 10:18:29 +00:00
|
|
|
|
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
|
|
|
|
|
|
2010-03-17 10:22:07 +00:00
|
|
|
|
check dashboard view on menu name field.
|
2010-03-18 10:18:29 +00:00
|
|
|
|
@return: False
|
2010-03-17 10:22:07 +00:00
|
|
|
|
"""
|
2010-03-17 05:06:34 +00:00
|
|
|
|
data = context and context.get('active_id', False) or False
|
|
|
|
|
if data:
|
|
|
|
|
return False
|
2010-03-18 10:18:29 +00:00
|
|
|
|
|
2010-03-18 11:22:25 +00:00
|
|
|
|
|
2010-03-17 05:06:34 +00:00
|
|
|
|
def board_menu_create(self, cr, uid, ids, context=None):
|
2010-03-15 13:53:05 +00:00
|
|
|
|
"""
|
|
|
|
|
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
|
2010-03-26 13:27:16 +00:00
|
|
|
|
@return: Dictionary {}.
|
2010-03-15 13:53:05 +00:00
|
|
|
|
"""
|
2010-11-23 07:05:05 +00:00
|
|
|
|
if context is None:
|
2010-03-17 10:22:07 +00:00
|
|
|
|
context = {}
|
2010-03-18 10:18:29 +00:00
|
|
|
|
|
2010-03-17 05:06:34 +00:00
|
|
|
|
context_id = context and context.get('active_id', False) or False
|
|
|
|
|
if context_id:
|
2010-11-19 13:48:01 +00:00
|
|
|
|
board = self.pool.get('board.board').browse(cr, uid, context_id, context=context)
|
2010-03-17 05:06:34 +00:00
|
|
|
|
action_id = self.pool.get('ir.actions.act_window').create(cr, uid, {
|
|
|
|
|
'name': board.name,
|
2010-03-26 13:27:16 +00:00
|
|
|
|
'view_type': 'form',
|
|
|
|
|
'view_mode': 'form',
|
2010-03-17 05:06:34 +00:00
|
|
|
|
'res_model': 'board.board',
|
|
|
|
|
'view_id': board.view_id.id,
|
2012-08-05 07:20:27 +00:00
|
|
|
|
'help': _('''<div class="oe_empty_custom_dashboard">
|
|
|
|
|
<p>
|
|
|
|
|
<b>This dashboard is empty.</b>
|
|
|
|
|
</p><p>
|
|
|
|
|
To add the first report into this dashboard, go to any
|
|
|
|
|
menu, switch to list or graph view, and click <i>'Add to
|
|
|
|
|
Dashboard'</i> in the extended search options.
|
|
|
|
|
</p><p>
|
|
|
|
|
You can filter and group data before inserting into the
|
|
|
|
|
dashboard using the search options.
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
''')
|
2010-03-17 05:06:34 +00:00
|
|
|
|
})
|
2010-03-18 10:18:29 +00:00
|
|
|
|
obj_menu = self.pool.get('ir.ui.menu')
|
|
|
|
|
#start Loop
|
2011-02-15 10:55:09 +00:00
|
|
|
|
for data in self.browse(cr, uid, ids, context=context):
|
2010-03-17 05:06:34 +00:00
|
|
|
|
obj_menu.create(cr, uid, {
|
2011-02-15 10:55:09 +00:00
|
|
|
|
'name': data.menu_name,
|
|
|
|
|
'parent_id': data.menu_parent_id.id,
|
2010-03-17 10:22:07 +00:00
|
|
|
|
'action': 'ir.actions.act_window,' + str(action_id)
|
2010-03-17 05:06:34 +00:00
|
|
|
|
}, context=context)
|
|
|
|
|
#End Loop
|
2010-12-28 10:44:45 +00:00
|
|
|
|
return {'type': 'ir.actions.act_window_close'}
|
2010-03-18 10:18:29 +00:00
|
|
|
|
|
2010-03-15 13:53:05 +00:00
|
|
|
|
_name = "board.menu.create"
|
|
|
|
|
_description = "Menu Create"
|
2010-03-18 10:18:29 +00:00
|
|
|
|
|
2010-03-15 13:53:05 +00:00
|
|
|
|
_columns = {
|
2010-03-17 10:22:07 +00:00
|
|
|
|
'menu_name': fields.char('Menu Name', size=64, required=True),
|
|
|
|
|
'menu_parent_id': fields.many2one('ir.ui.menu', 'Parent Menu', required=True),
|
2010-03-15 13:53:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
board_menu_create()
|
|
|
|
|
|
|
|
|
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
|
|
|
|