1 # -*- coding: utf-8 -*-
2 ##############################################################################
4 # OpenERP, Open Source Management Solution
5 # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU Affero General Public License as
9 # published by the Free Software Foundation, either version 3 of the
10 # License, or (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU Affero General Public License for more details.
17 # You should have received a copy of the GNU Affero General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 ##############################################################################
22 from osv import fields, osv
23 from tools.translate import _
25 class board_menu_create(osv.osv_memory):
29 def view_init(self, cr, uid, fields, context=None):
31 This function checks for precondition before wizard executes
32 @param self: The object pointer
33 @param cr: the current row, from the database cursor,
34 @param uid: the current user’s ID for security checks,
35 @param fields: List of fields for default value
36 @param context: A standard dictionary for contextual values
38 check dashboard view on menu name field.
41 data = context and context.get('active_id', False) or False
43 board = self.pool.get('board.board').browse(cr, uid, data, context=context)
44 if not board.line_ids:
45 raise osv.except_osv(_('User Error!'),
46 _('Please Insert Dashboard View(s) !'))
50 def board_menu_create(self, cr, uid, ids, context=None):
53 @param cr: the current row, from the database cursor,
54 @param uid: the current user’s ID for security checks,
55 @param ids: List of Board Menu Create's IDs
56 @return: Dictionary {}.
61 context_id = context and context.get('active_id', False) or False
63 board = self.pool.get('board.board').browse(cr, uid, context_id, context=context)
64 action_id = self.pool.get('ir.actions.act_window').create(cr, uid, {
68 'res_model': 'board.board',
69 'view_id': board.view_id.id,
71 obj_menu = self.pool.get('ir.ui.menu')
73 for data in self.read(cr, uid, ids):
74 obj_menu.create(cr, uid, {
75 'name': data.get('menu_name'),
76 'parent_id': data.get('menu_parent_id'),
77 'icon': 'STOCK_SELECT_COLOR',
78 'action': 'ir.actions.act_window,' + str(action_id)
81 return {'type': 'ir.actions.act_window_close'}
83 _name = "board.menu.create"
84 _description = "Menu Create"
87 'menu_name': fields.char('Menu Name', size=64, required=True),
88 'menu_parent_id': fields.many2one('ir.ui.menu', 'Parent Menu', required=True),
93 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: