diff options
| author | Antony Lesuisse <al@openerp.com> | 2012-08-03 17:46:41 +0200 |
|---|---|---|
| committer | Antony Lesuisse <al@openerp.com> | 2012-08-03 17:46:41 +0200 |
| commit | 788b1bdb5b2809c44fb814b4ebf67bd23efa6f32 (patch) | |
| tree | 7ae642057a1f229d5823682bfea2c5979120fa95 /addons/document_page/wizard | |
| parent | 96c7c90cdd49b376ad7c2ba8642f54f02124a5f3 (diff) | |
[REM] correctly rename and remove wiki
bzr revid: al@openerp.com-20120803154641-ocbydlqt7ppjecwn
Diffstat (limited to 'addons/document_page/wizard')
9 files changed, 534 insertions, 0 deletions
diff --git a/addons/document_page/wizard/__init__.py b/addons/document_page/wizard/__init__.py new file mode 100644 index 00000000000..a110b8175af --- /dev/null +++ b/addons/document_page/wizard/__init__.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# 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 +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +############################################################################## + +import document_page_page_open +import document_page_make_index +import document_page_create_menu +import document_page_show_diff + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: 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 (<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 +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +############################################################################## + +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: diff --git a/addons/document_page/wizard/document_page_create_menu_view.xml b/addons/document_page/wizard/document_page_create_menu_view.xml new file mode 100644 index 00000000000..a9af396d91f --- /dev/null +++ b/addons/document_page/wizard/document_page_create_menu_view.xml @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="utf-8"?> +<openerp> + <data> + +<!-- Create Menu From view --> + + <record id="view_wiki_create_menu" model="ir.ui.view"> + <field name="name">Create Menu</field> + <field name="model">document.page.create.menu</field> + <field name="type">form</field> + <field name="arch" type="xml"> + <form string="Create Menu" version="7.0"> + <group string="Menu Information"> + <field name="menu_name" /> + <field name="menu_parent_id" /> + </group> + <footer> + <button name="document_page_menu_create" string="Create Menu" type="object" class="oe_highlight"/> + or + <button string="Cancel" class="oe_link" special="cancel" /> + </footer> + </form> + </field> + </record> + +<!-- Create Menu Action --> + + <record id="action_wiki_create_menu" model="ir.actions.act_window"> + <field name="name">Create Menu</field> + <field name="type">ir.actions.act_window</field> + <field name="res_model">document.page.create.menu</field> + <field name="view_type">form</field> + <field name="view_mode">form</field> + <field name="target">new</field> + </record> + + </data> +</openerp> diff --git a/addons/document_page/wizard/document_page_make_index.py b/addons/document_page/wizard/document_page_make_index.py new file mode 100644 index 00000000000..801ea802b3d --- /dev/null +++ b/addons/document_page/wizard/document_page_make_index.py @@ -0,0 +1,83 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# 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 +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +############################################################################## + +from osv import fields, osv +from tools.translate import _ + +class document_page_make_index(osv.osv_memory): + """ Create Index For Selected Page """ + + _name = "document.page.make.index" + _description = "Create Index" + + def document_page_do_index(self, cr, uid, ids, context=None): + + """ Makes Index according to page hierarchy + @param cr: the current row, from the database cursor, + @param uid: the current user’s ID for security checks, + @param ids: list of document page index’s IDs + + """ + if context is None: + context = {} + data = context and context.get('active_ids', []) or [] + print 'data',tuple(data) + if not data: + return {'type': 'ir.actions.act_window_close'} + + for index_obj in self.browse(cr, uid, ids, context=context): + document_obj = self.pool.get('document.page') + if not ids: + return {} + cr.execute('select id,index,parent_id from document_page where id in %s '\ + 'and type=%s' ,(tuple(data),'index',)) + lst_all = cr.fetchall() + ls_p = [] + ls_np =[] + s_ids = {} + p_ids = {} + for m in lst_all: + if m[2] == None: + ls_np.append(m) + if m[1]: + s_ids[int(m[1])] = ls_np.index(m)+1 + if s_ids: + document_obj.write(cr, uid, m[0], {'index':s_ids[int(m[1])]}) + if m[2]: + ls_p.append(m) + if m[1]: + dict = {} + for l in ls_p: + if l[2] not in dict: + dict[l[2]] = [] + dict[l[2]].append(l) + else: + dict[l[2]].append(l) + + p_ids[m[1]] = str(m[2]) + "." + str(dict[m[2]].index(m)+1) + if p_ids: + document_obj.write(cr, uid, m[0], {'index':p_ids[m[1]]}) + + return {'type': 'ir.actions.act_window_close'} + +document_page_make_index() + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/document_page/wizard/document_page_make_index_view.xml b/addons/document_page/wizard/document_page_make_index_view.xml new file mode 100644 index 00000000000..70148850fbf --- /dev/null +++ b/addons/document_page/wizard/document_page_make_index_view.xml @@ -0,0 +1,42 @@ +<?xml version="1.0" encoding="utf-8"?> +<openerp> + <data> + +<!-- Create Index Form view --> + + <record id="view_wiki_make_index" model="ir.ui.view"> + <field name="name">Create Index</field> + <field name="model">document.page.make.index</field> + <field name="type">form</field> + <field name="arch" type="xml"> + <form string="Create Index" version="7.0"> + <label string="Want to create a Index on Selected Pages ? "/> + <footer> + <button name="document_page_do_index" string="Create Index" type="object" class="oe_highlight"/> + or + <button string="Cancel" class="oe_link" special="cancel" /> + </footer> + </form> + </field> + </record> + +<!-- Create Index Action --> + + <record id="action_view_wiki_make_index" model="ir.actions.act_window"> + <field name="name">Create Index</field> + <field name="type">ir.actions.act_window</field> + <field name="res_model">document.page.make.index</field> + <field name="view_type">form</field> + <field name="view_mode">form</field> + <field name="target">new</field> + </record> + +<!-- Create Index Action Window --> + + <act_window id="action_view_wiki_make_index_values" + key2="client_action_multi" name="Create Index" + res_model="document.page.make.index" src_model="document.page" + view_mode="form" target="new" view_type="form" /> + + </data> +</openerp> diff --git a/addons/document_page/wizard/document_page_open.py b/addons/document_page/wizard/document_page_open.py new file mode 100644 index 00000000000..6f6b5d3ee8a --- /dev/null +++ b/addons/document_page/wizard/document_page_open.py @@ -0,0 +1,65 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# 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 +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +############################################################################## + +from osv import osv + +class document_page_page_open(osv.osv_memory): + """ wizard Open Page """ + + _name = "document.page.page.open" + _description = "wiz open page" + + def open_document_page(self, cr, uid, ids, context=None): + + """ Opens Wiki Page of Group + @param cr: the current row, from the database cursor, + @param uid: the current user’s ID for security checks, + @param ids: List of open wiki page’s IDs + @return: dictionay of open wiki window on give group id + """ + if context is None: + context = {} + group_ids = context.get('active_ids', []) + for group in self.pool.get('document.page.type').browse(cr, uid, group_ids, context=context): + value = { + 'name': 'Document Page', + 'view_type': 'form', + 'view_mode': 'form,tree', + 'res_model': 'document.page', + 'view_id': False, + 'type': 'ir.actions.act_window', + } + 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 = self.pool.get('ir.ui.view').search(cr, uid, [('name', '=', 'document.page.tree.children')]) + value['view_id'] = view_id + value['domain'] = [('parent_id', '=', False)] + value['view_type'] = 'tree' + + return value + +document_page_page_open() + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/document_page/wizard/document_page_open_view.xml b/addons/document_page/wizard/document_page_open_view.xml new file mode 100644 index 00000000000..31df405b921 --- /dev/null +++ b/addons/document_page/wizard/document_page_open_view.xml @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="utf-8"?> +<openerp> + <data> + +<!-- Open Page Form view --> + + <record id="view_wiki_wiki_page_open" model="ir.ui.view"> + <field name="name">Open Page</field> + <field name="model">document.page.page.open</field> + <field name="type">form</field> + <field name="arch" type="xml"> + <form string="Open Page" version="7.0"> + <label string="Want to open a Document page? "/> + <footer> + <button name="open_document_page" string="Open Document Page" type="object" class="oe_highlight"/> + or + <button string="Cancel" class="oe_link" special="cancel" /> + </footer> + </form> + </field> + </record> + +<!-- Open Page Action --> + + <record id="action_view_wiki_wiki_page_open" model="ir.actions.act_window"> + <field name="name">Open Page</field> + <field name="type">ir.actions.act_window</field> + <field name="res_model">document.page.page.open</field> + <field name="view_type">form</field> + <field name="view_mode">form</field> + <field name="target">new</field> + </record> + </data> +</openerp> diff --git a/addons/document_page/wizard/document_page_show_diff.py b/addons/document_page/wizard/document_page_show_diff.py new file mode 100644 index 00000000000..fc5711ce733 --- /dev/null +++ b/addons/document_page/wizard/document_page_show_diff.py @@ -0,0 +1,69 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# 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 +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +############################################################################## + +from osv import fields, osv +from tools.translate import _ +import base64 + +class showdiff(osv.osv_memory): + """ Disp[ay Difference for History """ + + _name = 'wizard.document.page.history.show_diff' + + def get_diff(self, cr, uid, context=None): + + """ @param cr: the current row, from the database cursor, + @param uid: the current user’s ID for security checks, + """ + if context is None: + context = {} + history = self.pool.get('document.page.history') + ids = context.get('active_ids', []) + + diff = "" + if len(ids) == 2: + if ids[0] > ids[1]: + diff = base64.encodestring(history.getDiff(cr, uid, ids[1], ids[0])) + else: + diff = base64.encodestring(history.getDiff(cr, uid, ids[0], ids[1])) + + elif len(ids) == 1: + old = history.browse(cr, uid, ids[0]) + nids = history.search(cr, uid, [('document_id', '=', old.document_id.id)]) + nids.sort() + diff = base64.encodestring(history.getDiff(cr, uid, ids[0], nids[-1])) + else: + raise osv.except_osv(_('Warning'), _('You need to select minimum 1 or maximum 2 history revision!')) + + + return diff + + _columns = { + 'file_path':fields.binary('Diff', readonly=True), + } + + _defaults = { + 'file_path': get_diff + } + +showdiff() + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/document_page/wizard/document_page_show_diff_view.xml b/addons/document_page/wizard/document_page_show_diff_view.xml new file mode 100644 index 00000000000..9c58242844d --- /dev/null +++ b/addons/document_page/wizard/document_page_show_diff_view.xml @@ -0,0 +1,41 @@ +<?xml version="1.0" encoding="utf-8"?> +<openerp> + <data> + +<!-- Create Index Form view --> + + <record id="view_wiki_show_diff" model="ir.ui.view"> + <field name="name">Show Difference</field> + <field name="model">wizard.document.page.history.show_diff</field> + <field name="type">form</field> + <field name="arch" type="xml"> + <form string="Difference" version="7.0"> + <separator string="Notes"/> + <field name="file_path" width="300"/> + <footer> + <button string="Cancel" class="oe_link" special="cancel" /> + </footer> + </form> + </field> + </record> + +<!-- Create Index Action --> + + <record id="action_view_wiki_show_diff" model="ir.actions.act_window"> + <field name="name">Difference</field> + <field name="type">ir.actions.act_window</field> + <field name="res_model">wizard.document.page.history.show_diff</field> + <field name="view_type">form</field> + <field name="view_mode">form</field> + <field name="target">new</field> + </record> + +<!-- Create Index Action Window --> + + <act_window id="action_view_wiki_show_diff_values" + key2="client_action_multi" name="Difference" + res_model="wizard.document.page.history.show_diff" src_model="document.page.history" + view_mode="form" target="new" view_type="form" /> + + </data> +</openerp> |
