diff --git a/addons/document_page/document_page.py b/addons/document_page/document_page.py
index 3af2417b651..dbba0fc00d7 100644
--- a/addons/document_page/document_page.py
+++ b/addons/document_page/document_page.py
@@ -29,72 +29,72 @@ class document_page(osv.osv):
_description = "Document Page"
_order = 'name'
- _columns = {
- 'name': fields.char('Title', size=256, select=True, required=True),
- 'type':fields.selection([('normal','Content Page'), ('index','Index Page')], 'Type', help="Define the type of the document"),
+ def _get_page_index(self, cr, uid, page):
+ index == []
+ for subpage in page.child_ids:
+ index += ["
"+ self._get_page_index(cr, uid, subpage) +""]
+ if index:
+ index = ""
+ else:
+ index = page.title
- 'parent_id': fields.many2one('document.page', 'Section', select=1 , ondelete='set null'),
+ def _get_display_content(self, cr, uid, ids, name, args, context=None):
+ res = {}
+ for page in self.browse(cr, uid, ids, context=context):
+ if parent.type == "index":
+ content = self._get_page_index(cr, uid, page)
+ else:
+ content = page.content
+ res[page.id] = {
+ 'display_content': content
+ }
+ return res
+
+ _columns = {
+ 'name': fields.char('Title', required=True),
+ 'type':fields.selection([('content','Content Page'), ('index','Index Page')], 'Type', help="Page type"),
+
+ 'parent_id': fields.many2one('document.page', 'Section'),
'child_ids': fields.one2many('document.page', 'parent_id', 'Children'),
- 'display_content': fields.text('Displayed Content'),
'content': fields.text("Content"),
+ 'display_content': fields.function(_get_display_content, string='Displayed Content', type='text'),
+
'history_ids': fields.one2many('document.page.history', 'document_id', 'History'),
'menu_id': fields.many2one('ir.ui.menu', "Menu", readonly=True),
'create_date': fields.datetime("Created on", select=True, readonly=True),
+ 'create_uid': fields.many2one('res.users', 'Author', select=True, readonly=True),
'write_date': fields.datetime("Modification Date", select=True, readonly=True),
'write_uid': fields.many2one('res.users', "Last Contributor", select=True),
- 'create_uid': fields.many2one('res.users', 'Author', select=True, readonly=True),
-
- 'index': fields.char('Index', size=256),
- 'minor_edit': fields.boolean('Minor edit', select=True),
- 'edit_summary': fields.char('Summary', size=256),
- 'tags': fields.char('Keywords', size=1024, select=True),
-
}
_defaults = {
- 'type':'normal',
+ 'type':'content',
}
def onchange_parent_id(self, cr, uid, ids, parent_id, content, context=None):
- if (not parent_id) or content:
- return {}
- grp = self.pool.get('document.page.type').browse(cr, uid, parent_id, context=context)
- template = grp.content_template
- try:
- s[-1] = str(int(s[-1])+1)
- except:
- pass
- return {
- 'value':{
- 'content': template,
- }
- }
-
- def onchange_content(self, cr, uid, ids, content, context=None):
- if content:
- return {'value':{'summary': content}}
- return {}
-
- def copy_data(self, cr, uid, id, default=None, context=None):
- return super(document_page2, self).copy_data(cr, uid, id, {'document_id': False}, context)
+ res = {}
+ if parent_id and not content:
+ parent = self.browse(cr, uid, parent_id, context=context)
+ if parent.type == "content":
+ res['value'] = {
+ 'content': parent.content_template,
+ }
+ return res
def create_history(self, cr, uid, ids, vals, context=None):
- history_id = False
- history = self.pool.get('document.page.history')
- if vals.get('content'):
- res = {
- 'content': vals.get('content', ''),
- 'write_uid': uid,
- 'document_id': ids[0],
- 'summary':vals.get('edit_summary', '')
- }
- history_id = history.create(cr, uid, res)
- return history_id
+ for i in ids:
+ history = self.pool.get('document.page.history')
+ if vals.get('content'):
+ res = {
+ 'content': vals.get('content', ''),
+ 'page_id': i,
+ }
+ history.create(cr, uid, res)
def create(self, cr, uid, vals, context=None):
- document_id = super(document_page2, self).create(cr, uid, vals, context)
- self.create_history(cr, uid, [document_id], vals, context)
+ page_id = super(document_page2, self).create(cr, uid, vals, context)
+ self.create_history(cr, uid, [page_id], vals, context)
return document_id
def write(self, cr, uid, ids, vals, context=None):
@@ -102,23 +102,18 @@ class document_page(osv.osv):
self.create_history(cr, uid, ids, vals, context)
return result
-
class document_page_history(osv.osv):
_name = "document.page.history"
_description = "Document Page History"
- _rec_name = "summary"
_order = 'id DESC'
+ _rec_name = "create_date"
_columns = {
- 'document_id': fields.many2one('document.page', 'Document Page', select=True)
+ 'page_id': fields.many2one('document.page', 'Page'),
'summary': fields.char('Summary', size=256, select=True),
'content': fields.text("Content"),
- 'create_date': fields.datetime("Date", select=True),
- 'write_uid': fields.many2one('res.users', "Modify By", select=True),
- }
-
- _defaults = {
- 'write_uid': lambda obj, cr, uid, context: uid,
+ 'create_date': fields.datetime("Date"),
+ 'create_uid': fields.many2one('res.users', "Modified By"),
}
def getDiff(self, cr, uid, v1, v2, context=None):
diff --git a/addons/document_page/wizard/__init__.py b/addons/document_page/wizard/__init__.py
index a110b8175af..e24534647f4 100644
--- a/addons/document_page/wizard/__init__.py
+++ b/addons/document_page/wizard/__init__.py
@@ -19,8 +19,6 @@
#
##############################################################################
-import document_page_page_open
-import document_page_make_index
import document_page_create_menu
import document_page_show_diff
diff --git a/addons/document_page/wizard/document_page_make_index.py b/addons/document_page/wizard/document_page_make_index.py
deleted file mode 100644
index 801ea802b3d..00000000000
--- a/addons/document_page/wizard/document_page_make_index.py
+++ /dev/null
@@ -1,83 +0,0 @@
-# -*- 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
-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
deleted file mode 100644
index 70148850fbf..00000000000
--- a/addons/document_page/wizard/document_page_make_index_view.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-
-
-
-
-
-
-
- Create Index
- document.page.make.index
- form
-
-
-
-
-
-
-
-
- Create Index
- ir.actions.act_window
- document.page.make.index
- form
- form
- new
-
-
-
-
-
-
-
-
diff --git a/addons/document_page/wizard/document_page_open.py b/addons/document_page/wizard/document_page_open.py
deleted file mode 100644
index 6f6b5d3ee8a..00000000000
--- a/addons/document_page/wizard/document_page_open.py
+++ /dev/null
@@ -1,65 +0,0 @@
-# -*- 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 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
deleted file mode 100644
index 31df405b921..00000000000
--- a/addons/document_page/wizard/document_page_open_view.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-
-
-
-
-
-
-
- Open Page
- document.page.page.open
- form
-
-
-
-
-
-
-
-
- Open Page
- ir.actions.act_window
- document.page.page.open
- form
- form
- new
-
-
-