summaryrefslogtreecommitdiff
path: root/addons/document_page/wizard
diff options
context:
space:
mode:
authorRucha (Open ERP) <rpa@tinyerp.com>2012-08-13 10:44:11 +0530
committerRucha (Open ERP) <rpa@tinyerp.com>2012-08-13 10:44:11 +0530
commitdd7a2972d8099fdc8ccb17ee6b7a56a4be2bbb1f (patch)
tree255b0bb9cba8bd5ecd542db5ed3fdc79a004cba0 /addons/document_page/wizard
parent7739d0d69b856c3eca8282e52100a06fe6ab2ff3 (diff)
parent9211174a6fbbec8d2637c7d9295714c1657dd8ee (diff)
[MERGE]: Merge with latest trunk-addons
bzr revid: rpa@tinyerp.com-20120813051411-5no0xcudwbkw07c5
Diffstat (limited to 'addons/document_page/wizard')
-rw-r--r--addons/document_page/wizard/__init__.py25
-rw-r--r--addons/document_page/wizard/document_page_create_menu.py87
-rw-r--r--addons/document_page/wizard/document_page_create_menu_view.xml34
-rw-r--r--addons/document_page/wizard/document_page_show_diff.py61
-rw-r--r--addons/document_page/wizard/document_page_show_diff_view.xml40
-rw-r--r--addons/document_page/wizard/wiki_make_index.py100
-rw-r--r--addons/document_page/wizard/wiki_make_index_view.xml43
-rw-r--r--addons/document_page/wizard/wiki_wiki_page_open.py66
-rw-r--r--addons/document_page/wizard/wiki_wiki_page_open_view.xml34
9 files changed, 490 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..e24534647f4
--- /dev/null
+++ b/addons/document_page/wizard/__init__.py
@@ -0,0 +1,25 @@
+# -*- 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_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..68697233f84
--- /dev/null
+++ b/addons/document_page/wizard/document_page_create_menu.py
@@ -0,0 +1,87 @@
+# -*- 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, 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 = {}
+ 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')
+ page_id = context.get('active_id', False)
+ page = obj_page.browse(cr, uid, page_id, context=context)
+
+ 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',
+ 'target': 'inlineview',
+ 'nodestroy': True,
+ }
+ 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,
+ 'parent_id':data.menu_parent_id.id,
+ 'icon': 'STOCK_DIALOG_QUESTION',
+ 'action': 'ir.actions.act_window,'+ str(action_id),
+ }, context)
+ obj_page.write(cr, uid, [page_id], {'menu_id':menu_id})
+ return {
+ 'type': 'ir.actions.client',
+ 'tag': 'reload',
+ }
+
+
+# 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..6d689dfe41d
--- /dev/null
+++ b/addons/document_page/wizard/document_page_create_menu_view.xml
@@ -0,0 +1,34 @@
+<?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_show_diff.py b/addons/document_page/wizard/document_page_show_diff.py
new file mode 100644
index 00000000000..ab5572768f4
--- /dev/null
+++ b/addons/document_page/wizard/document_page_show_diff.py
@@ -0,0 +1,61 @@
+# -*- 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):
+ 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 = history.getDiff(cr, uid, ids[1], ids[0])
+ else:
+ diff = 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 = history.getDiff(cr, uid, ids[0], nids[-1])
+ else:
+ raise osv.except_osv(_('Warning!'), _('You need to select minimum one or maximum two history revisions!'))
+ return diff
+
+ _columns = {
+ 'diff': fields.text('Diff', readonly=True),
+ }
+
+ _defaults = {
+ 'diff': get_diff
+ }
+
+# 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..c6066669dca
--- /dev/null
+++ b/addons/document_page/wizard/document_page_show_diff_view.xml
@@ -0,0 +1,40 @@
+<?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">
+ <field name="diff"/>
+ <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>
diff --git a/addons/document_page/wizard/wiki_make_index.py b/addons/document_page/wizard/wiki_make_index.py
new file mode 100644
index 00000000000..27978f9b8ec
--- /dev/null
+++ b/addons/document_page/wizard/wiki_make_index.py
@@ -0,0 +1,100 @@
+# -*- 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 wiki_make_index(osv.osv_memory):
+ """ Create Index For Selected Page """
+
+ _name = "wiki.make.index"
+ _description = "Create Index"
+
+ def wiki_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 wiki index’s IDs
+
+ """
+ if context is None:
+ context = {}
+ data = context and context.get('active_ids', []) or []
+
+ if not data:
+ return {'type': 'ir.actions.act_window_close'}
+
+ for index_obj in self.browse(cr, uid, ids, context=context):
+ wiki_pool = self.pool.get('wiki.wiki')
+ cr.execute("Select id, section from wiki_wiki where id IN %s \
+ order by section ", (tuple(data),))
+ lst0 = cr.fetchall()
+ if not lst0[0][1]:
+ raise osv.except_osv(_('Warning !'), _('There is no section in this Page'))
+
+ lst = []
+ s_ids = {}
+
+ for l in lst0:
+ s_ids[l[1]] = l[0]
+ lst.append(l[1])
+
+ lst.sort()
+ val = None
+ def toint(x):
+ try:
+ return int(x)
+ except:
+ return 1
+
+ lst = map(lambda x: map(toint, x.split('.')), lst)
+
+ result = []
+ current = ['0']
+ current2 = []
+
+ for l in lst:
+ for pos in range(len(l)):
+ if pos >= len(current):
+ current.append('1')
+ continue
+ if (pos == len(l) - 1) or (pos >= len(current2)) or (toint(l[pos]) > toint(current2[pos])):
+ current[pos] = str(toint(current[pos]) + 1)
+ current = current[:pos + 1]
+ if pos == len(l) - 1:
+ break
+ key = ('.'.join([str(x) for x in l]))
+ id = s_ids[key]
+ val = ('.'.join([str(x) for x in current[:]]), id)
+
+ if val:
+ result.append(val)
+ current2 = l
+
+ for rs in result:
+ wiki_pool.write(cr, uid, [rs[1]], {'section':rs[0]})
+
+ return {'type': 'ir.actions.act_window_close'}
+
+wiki_make_index()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/document_page/wizard/wiki_make_index_view.xml b/addons/document_page/wizard/wiki_make_index_view.xml
new file mode 100644
index 00000000000..90139c3afac
--- /dev/null
+++ b/addons/document_page/wizard/wiki_make_index_view.xml
@@ -0,0 +1,43 @@
+<?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">wiki.make.index</field>
+ <field name="type">form</field>
+ <field name="arch" type="xml">
+ <form string="Create Menu" version="7.0">
+ <separator string="Menu Information"/>
+ <label string="Want to create a Index on Selected Pages ? "/>
+ <footer>
+ <button name="wiki_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">wiki.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="wiki.make.index" src_model="wiki.wiki"
+ view_mode="form" target="new" view_type="form" />
+
+ </data>
+</openerp>
diff --git a/addons/document_page/wizard/wiki_wiki_page_open.py b/addons/document_page/wizard/wiki_wiki_page_open.py
new file mode 100644
index 00000000000..215a49f29fe
--- /dev/null
+++ b/addons/document_page/wizard/wiki_wiki_page_open.py
@@ -0,0 +1,66 @@
+# -*- 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 wiki_wiki_page_open(osv.osv_memory):
+ """ wizard Open Page """
+
+ _name = "wiki.wiki.page.open"
+ _description = "wiz open page"
+
+ def open_wiki_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('wiki.groups').browse(cr, uid, group_ids, context=context):
+ value = {
+ 'domain': "[('group_id','=',%d)]" % (group.id),
+ 'name': 'Wiki Page',
+ 'view_type': 'form',
+ 'view_mode': 'form,tree',
+ 'res_model': 'wiki.wiki',
+ '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', '=', 'wiki.wiki.tree.children')])
+ value['view_id'] = view_id
+ value['domain'] = [('group_id', '=', group.id), ('parent_id', '=', False)]
+ value['view_type'] = 'tree'
+
+ return value
+
+wiki_wiki_page_open()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/document_page/wizard/wiki_wiki_page_open_view.xml b/addons/document_page/wizard/wiki_wiki_page_open_view.xml
new file mode 100644
index 00000000000..49f333e453f
--- /dev/null
+++ b/addons/document_page/wizard/wiki_wiki_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">wiki.wiki.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 wiki page? "/>
+ <footer>
+ <button name="open_wiki_page" string="Open Wiki 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">wiki.wiki.page.open</field>
+ <field name="view_type">form</field>
+ <field name="view_mode">form</field>
+ <field name="target">new</field>
+ </record>
+ </data>
+</openerp>