2009-10-13 05:58:37 +00:00
|
|
|
|
# -*- coding: utf-8 -*-
|
2008-08-24 14:45:43 +00:00
|
|
|
|
##############################################################################
|
2009-10-14 11:15:34 +00:00
|
|
|
|
#
|
|
|
|
|
# OpenERP, Open Source Management Solution
|
2010-01-12 09:18:39 +00:00
|
|
|
|
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
2008-08-24 14:45:43 +00:00
|
|
|
|
#
|
2008-11-03 19:18:56 +00:00
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
2009-10-14 11:15:34 +00:00
|
|
|
|
# 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.
|
2008-08-24 14:45:43 +00:00
|
|
|
|
#
|
2008-11-03 19:18:56 +00:00
|
|
|
|
# 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
|
2009-10-14 11:15:34 +00:00
|
|
|
|
# GNU Affero General Public License for more details.
|
2008-08-24 14:45:43 +00:00
|
|
|
|
#
|
2009-10-14 11:15:34 +00:00
|
|
|
|
# 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/>.
|
2008-08-24 14:45:43 +00:00
|
|
|
|
#
|
|
|
|
|
##############################################################################
|
|
|
|
|
|
2010-03-11 05:40:47 +00:00
|
|
|
|
from osv import fields, osv
|
2008-08-24 14:45:43 +00:00
|
|
|
|
|
2010-03-11 05:40:47 +00:00
|
|
|
|
class report_menu_create(osv.osv_memory):
|
|
|
|
|
"""
|
|
|
|
|
Create Menu
|
|
|
|
|
"""
|
|
|
|
|
_name = "report.menu.create"
|
|
|
|
|
_description = "Menu Create"
|
2010-03-17 05:39:51 +00:00
|
|
|
|
_columns = {
|
2010-03-11 05:40:47 +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-17 05:39:51 +00:00
|
|
|
|
def report_menu_create(self, cr, uid, ids, context=None):
|
2010-03-11 05:40:47 +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 Report Menu Create's IDs
|
2010-03-17 12:55:17 +00:00
|
|
|
|
@return: Dictionary {}.
|
2010-03-11 05:40:47 +00:00
|
|
|
|
"""
|
2010-11-23 07:05:05 +00:00
|
|
|
|
if context is None:
|
2010-03-17 12:55:17 +00:00
|
|
|
|
context = {}
|
2010-03-17 05:39:51 +00:00
|
|
|
|
context_id = context and context.get('active_id', False) or False
|
2010-07-08 06:26:09 +00:00
|
|
|
|
obj_menu = self.pool.get('ir.ui.menu')
|
|
|
|
|
data_obj = self.pool.get('ir.model.data')
|
|
|
|
|
obj_board = self.pool.get('base_report_creator.report')
|
2010-03-17 05:39:51 +00:00
|
|
|
|
if context_id:
|
2010-07-08 06:26:09 +00:00
|
|
|
|
data = self.browse(cr, uid, ids, context=context)
|
|
|
|
|
if not data:
|
|
|
|
|
return {}
|
|
|
|
|
data = data[0]
|
|
|
|
|
|
|
|
|
|
board = obj_board.browse(cr, uid, context_id)
|
2010-03-17 05:39:51 +00:00
|
|
|
|
view = board.view_type1
|
|
|
|
|
if board.view_type2:
|
2010-03-17 12:55:17 +00:00
|
|
|
|
view += ',' + board.view_type2
|
2010-03-17 05:39:51 +00:00
|
|
|
|
if board.view_type3:
|
2010-03-17 12:55:17 +00:00
|
|
|
|
view += ',' + board.view_type3
|
2010-07-08 06:26:09 +00:00
|
|
|
|
|
|
|
|
|
result = data_obj._get_id(cr, uid, 'base_report_creator', 'view_report_filter')
|
|
|
|
|
res = data_obj.read(cr, uid, result, ['res_id'])
|
2010-03-17 05:39:51 +00:00
|
|
|
|
action_id = self.pool.get('ir.actions.act_window').create(cr, uid, {
|
|
|
|
|
'name': board.name,
|
|
|
|
|
'view_type':'form',
|
|
|
|
|
'view_mode':view,
|
|
|
|
|
'context': "{'report_id':%d}" % (board.id,),
|
2010-07-08 06:26:09 +00:00
|
|
|
|
'res_model': 'base_report_creator.report',
|
|
|
|
|
'search_view_id': res['res_id']
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
menu_id = obj_menu.create(cr, uid, {
|
|
|
|
|
'name': data.menu_name,
|
|
|
|
|
'parent_id': data.menu_parent_id.id,
|
2010-03-11 05:40:47 +00:00
|
|
|
|
'icon': 'STOCK_SELECT_COLOR',
|
2010-03-17 12:55:17 +00:00
|
|
|
|
'action': 'ir.actions.act_window, ' + str(action_id)
|
2010-03-17 05:39:51 +00:00
|
|
|
|
}, context=context)
|
2010-07-08 06:26:09 +00:00
|
|
|
|
obj_board.write(cr, uid, context_id, {'menu_id': menu_id})
|
|
|
|
|
return {}
|
2010-03-11 05:40:47 +00:00
|
|
|
|
report_menu_create()
|
2008-08-24 14:45:43 +00:00
|
|
|
|
|
|
|
|
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
|
|
|
|