From 788b1bdb5b2809c44fb814b4ebf67bd23efa6f32 Mon Sep 17 00:00:00 2001 From: Antony Lesuisse Date: Fri, 3 Aug 2012 17:46:41 +0200 Subject: [REM] correctly rename and remove wiki bzr revid: al@openerp.com-20120803154641-ocbydlqt7ppjecwn --- .../wizard/document_page_create_menu.py | 135 +++++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100644 addons/document_page/wizard/document_page_create_menu.py (limited to 'addons/document_page/wizard/document_page_create_menu.py') diff --git a/addons/document_page/wizard/document_page_create_menu.py b/addons/document_page/wizard/document_page_create_menu.py new file mode 100644 index 00000000000..9a351e0fe61 --- /dev/null +++ b/addons/document_page/wizard/document_page_create_menu.py @@ -0,0 +1,135 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# +# 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 . +# +############################################################################## + +from osv import fields, osv + +class document_page_create_menu(osv.osv_memory): + """ Create Menu """ + _name = "document.page.create.menu" + _description = "Wizard Create Menu" + + _columns = { + 'menu_name': fields.char('Menu Name', size=256, select=True, required=True), + 'menu_parent_id': fields.many2one('ir.ui.menu', 'Parent Menu', required=True), + } + + def wiki_menu_create(self, cr, uid, ids, context=None): + + """ Create Menu On the base of Group id and Action id + @param cr: the current row, from the database cursor, + @param uid: the current user’s ID for security checks, + @param ids: List of create menu’s IDs + + """ + if context is None: + context = {} + obj_wiki_group = self.pool.get('document.page.type') + obj_view = self.pool.get('ir.ui.view') + obj_menu = self.pool.get('ir.ui.menu') + obj_action = self.pool.get('ir.actions.act_window') + group_id = context.get('active_id', False) + if not group_id: + return {} + + datas = self.browse(cr, uid, ids, context=context) + data = False + if datas: + data = datas[0] + if not data: + return {} + value = { + 'name': 'Document Page', + 'view_type': 'form', + 'view_mode': 'form,tree', + 'res_model': 'document.page', + 'view_id': False, + 'type': 'ir.actions.act_window', + 'nodestroy': True, + } + group = obj_wiki_group.browse(cr, uid, group_id, context=context) + value['domain'] = "[('group_id','=',%d)]" % (group.id) + if group.method == 'page': + value['res_id'] = group.home.id + elif group.method == 'list': + value['view_type'] = 'form' + value['view_mode'] = 'tree,form' + elif group.method == 'tree': + view_id = obj_view.search(cr, uid, [('name', '=', 'document.page.tree.children')]) + value['view_id'] = view_id + value['domain'] = [('group_id', '=', group.id), ('parent_id', '=', False)] + value['view_type'] = 'tree' + + action_id = obj_action.create(cr, uid, value) + + menu_id = obj_menu.create(cr, uid, { + 'name': data.menu_name, + 'parent_id':data.menu_parent_id.id, + 'icon': 'STOCK_DIALOG_QUESTION', + 'action': 'ir.actions.act_window,'+ str(action_id), + }, context) + obj_wiki_group.write(cr, uid, [group_id], {'menu_id':menu_id}) + return {'type': 'ir.actions.act_window_close'} + + def document_page_menu_create(self, cr, uid, ids, context=None): + + if context is None: + context = {} + obj_document_group = self.pool.get('document.page') + obj_view = self.pool.get('ir.ui.view') + obj_menu = self.pool.get('ir.ui.menu') + obj_action = self.pool.get('ir.actions.act_window') + group_id = context.get('active_id', False) + if not group_id: + return {} + + datas = self.browse(cr, uid, ids, context=context) + data = False + if datas: + data = datas[0] + if not data: + return {} + value = { + 'name': 'Document Page', + 'view_type': 'form', + 'view_mode': 'form,tree', + 'res_model': 'document.page', + 'view_id': False, + 'type': 'ir.actions.act_window', + 'nodestroy': True, + } + group = obj_document_group.browse(cr, uid, group_id, context=context) + value['domain'] = "[('parent_id','=',%d)]" % (group.id) + value['res_id'] = group.id + + action_id = obj_action.create(cr, uid, value) + menu_id = obj_menu.create(cr, uid, { + 'name': data.menu_name, + 'parent_id':data.menu_parent_id.id, + 'icon': 'STOCK_DIALOG_QUESTION', + 'action': 'ir.actions.act_window,'+ str(action_id), + }, context) + obj_document_group.write(cr, uid, [group_id], {'menu_id':menu_id}) + return {'type': 'ir.actions.act_window_close'} + + +document_page_create_menu() + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: -- cgit v1.2.3 From bda8f3fb7f675957b7e0b1245a21196c11b47865 Mon Sep 17 00:00:00 2001 From: Antony Lesuisse Date: Fri, 10 Aug 2012 02:09:08 +0200 Subject: page mostly ok bzr revid: al@openerp.com-20120810000908-ujg81v4mgm22glem --- .../wizard/document_page_create_menu.py | 83 +++------------------- 1 file changed, 11 insertions(+), 72 deletions(-) (limited to 'addons/document_page/wizard/document_page_create_menu.py') diff --git a/addons/document_page/wizard/document_page_create_menu.py b/addons/document_page/wizard/document_page_create_menu.py index 9a351e0fe61..f35107511bf 100644 --- a/addons/document_page/wizard/document_page_create_menu.py +++ b/addons/document_page/wizard/document_page_create_menu.py @@ -27,77 +27,18 @@ class document_page_create_menu(osv.osv_memory): _description = "Wizard Create Menu" _columns = { - 'menu_name': fields.char('Menu Name', size=256, select=True, required=True), 'menu_parent_id': fields.many2one('ir.ui.menu', 'Parent Menu', required=True), } - def wiki_menu_create(self, cr, uid, ids, context=None): - - """ Create Menu On the base of Group id and Action id - @param cr: the current row, from the database cursor, - @param uid: the current user’s ID for security checks, - @param ids: List of create menu’s IDs - - """ - if context is None: - context = {} - obj_wiki_group = self.pool.get('document.page.type') - obj_view = self.pool.get('ir.ui.view') - obj_menu = self.pool.get('ir.ui.menu') - obj_action = self.pool.get('ir.actions.act_window') - group_id = context.get('active_id', False) - if not group_id: - return {} - - datas = self.browse(cr, uid, ids, context=context) - data = False - if datas: - data = datas[0] - if not data: - return {} - value = { - 'name': 'Document Page', - 'view_type': 'form', - 'view_mode': 'form,tree', - 'res_model': 'document.page', - 'view_id': False, - 'type': 'ir.actions.act_window', - 'nodestroy': True, - } - group = obj_wiki_group.browse(cr, uid, group_id, context=context) - value['domain'] = "[('group_id','=',%d)]" % (group.id) - if group.method == 'page': - value['res_id'] = group.home.id - elif group.method == 'list': - value['view_type'] = 'form' - value['view_mode'] = 'tree,form' - elif group.method == 'tree': - view_id = obj_view.search(cr, uid, [('name', '=', 'document.page.tree.children')]) - value['view_id'] = view_id - value['domain'] = [('group_id', '=', group.id), ('parent_id', '=', False)] - value['view_type'] = 'tree' - - action_id = obj_action.create(cr, uid, value) - - menu_id = obj_menu.create(cr, uid, { - 'name': data.menu_name, - 'parent_id':data.menu_parent_id.id, - 'icon': 'STOCK_DIALOG_QUESTION', - 'action': 'ir.actions.act_window,'+ str(action_id), - }, context) - obj_wiki_group.write(cr, uid, [group_id], {'menu_id':menu_id}) - return {'type': 'ir.actions.act_window_close'} - def document_page_menu_create(self, cr, uid, ids, context=None): - if context is None: context = {} - obj_document_group = self.pool.get('document.page') + obj_page = self.pool.get('document.page') obj_view = self.pool.get('ir.ui.view') obj_menu = self.pool.get('ir.ui.menu') obj_action = self.pool.get('ir.actions.act_window') - group_id = context.get('active_id', False) - if not group_id: + page_id = context.get('active_id', False) + if not page_id: return {} datas = self.browse(cr, uid, ids, context=context) @@ -106,30 +47,28 @@ class document_page_create_menu(osv.osv_memory): data = datas[0] if not data: return {} - value = { + value = { 'name': 'Document Page', 'view_type': 'form', 'view_mode': 'form,tree', 'res_model': 'document.page', 'view_id': False, 'type': 'ir.actions.act_window', + 'target': 'inline', 'nodestroy': True, } - group = obj_document_group.browse(cr, uid, group_id, context=context) - value['domain'] = "[('parent_id','=',%d)]" % (group.id) - value['res_id'] = group.id + page = obj_page.browse(cr, uid, page_id, context=context) + value['domain'] = "[('parent_id','=',%d)]" % (page.id) + value['res_id'] = page.id action_id = obj_action.create(cr, uid, value) menu_id = obj_menu.create(cr, uid, { - 'name': data.menu_name, + 'name': page.name, 'parent_id':data.menu_parent_id.id, 'icon': 'STOCK_DIALOG_QUESTION', 'action': 'ir.actions.act_window,'+ str(action_id), }, context) - obj_document_group.write(cr, uid, [group_id], {'menu_id':menu_id}) - return {'type': 'ir.actions.act_window_close'} - - -document_page_create_menu() + obj_page.write(cr, uid, [page_id], {'menu_id':menu_id}) + return {'type': 'ir.actions.act_window_close'} # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: -- cgit v1.2.3 From 4e4a7dcbeec869464a5fb442088217b0d6cb2fb7 Mon Sep 17 00:00:00 2001 From: Antony Lesuisse Date: Sat, 11 Aug 2012 00:50:46 +0200 Subject: document_page ready bzr revid: al@openerp.com-20120810225046-qs3liea2s76lh6v0 --- .../document_page/wizard/document_page_create_menu.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'addons/document_page/wizard/document_page_create_menu.py') diff --git a/addons/document_page/wizard/document_page_create_menu.py b/addons/document_page/wizard/document_page_create_menu.py index f35107511bf..591cc845a93 100644 --- a/addons/document_page/wizard/document_page_create_menu.py +++ b/addons/document_page/wizard/document_page_create_menu.py @@ -27,9 +27,20 @@ class document_page_create_menu(osv.osv_memory): _description = "Wizard Create Menu" _columns = { + 'menu_name': fields.char('Menu Name', size=256, required=True), 'menu_parent_id': fields.many2one('ir.ui.menu', 'Parent Menu', required=True), } + def default_get(self, cr, uid, fields, context=None): + if context is None: + context = {} + res = super(document_page_create_menu,self).default_get(cr, uid, fields, context=context) + page_id = context.get('active_id') + obj_page = self.pool.get('document.page') + page = obj_page.browse(cr, uid, page_id, context=context) + res['menu_name'] = page.name + return res + def document_page_menu_create(self, cr, uid, ids, context=None): if context is None: context = {} @@ -38,8 +49,7 @@ class document_page_create_menu(osv.osv_memory): obj_menu = self.pool.get('ir.ui.menu') obj_action = self.pool.get('ir.actions.act_window') page_id = context.get('active_id', False) - if not page_id: - return {} + page = obj_page.browse(cr, uid, page_id, context=context) datas = self.browse(cr, uid, ids, context=context) data = False @@ -57,13 +67,12 @@ class document_page_create_menu(osv.osv_memory): 'target': 'inline', 'nodestroy': True, } - page = obj_page.browse(cr, uid, page_id, context=context) value['domain'] = "[('parent_id','=',%d)]" % (page.id) value['res_id'] = page.id action_id = obj_action.create(cr, uid, value) menu_id = obj_menu.create(cr, uid, { - 'name': page.name, + 'name': data.menu_name, 'parent_id':data.menu_parent_id.id, 'icon': 'STOCK_DIALOG_QUESTION', 'action': 'ir.actions.act_window,'+ str(action_id), -- cgit v1.2.3 From d2a01d78a4b21a0b37a5decacee3d5443a91d9d6 Mon Sep 17 00:00:00 2001 From: Antony Lesuisse Date: Sat, 11 Aug 2012 20:34:44 +0200 Subject: fixes css, demo, js bzr revid: al@openerp.com-20120811183444-0wwagnum2tm964i6 --- addons/document_page/wizard/document_page_create_menu.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'addons/document_page/wizard/document_page_create_menu.py') diff --git a/addons/document_page/wizard/document_page_create_menu.py b/addons/document_page/wizard/document_page_create_menu.py index 591cc845a93..68697233f84 100644 --- a/addons/document_page/wizard/document_page_create_menu.py +++ b/addons/document_page/wizard/document_page_create_menu.py @@ -64,7 +64,7 @@ class document_page_create_menu(osv.osv_memory): 'res_model': 'document.page', 'view_id': False, 'type': 'ir.actions.act_window', - 'target': 'inline', + 'target': 'inlineview', 'nodestroy': True, } value['domain'] = "[('parent_id','=',%d)]" % (page.id) @@ -78,6 +78,10 @@ class document_page_create_menu(osv.osv_memory): 'action': 'ir.actions.act_window,'+ str(action_id), }, context) obj_page.write(cr, uid, [page_id], {'menu_id':menu_id}) - return {'type': 'ir.actions.act_window_close'} + return { + 'type': 'ir.actions.client', + 'tag': 'reload', + } + # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: -- cgit v1.2.3