From 3b1d14196a400f284c6b6379f912e067bc18ea2b Mon Sep 17 00:00:00 2001
From: Giorgio Borelli " + "".join(index) + "
"
return r
- def _get_display_content(self, cr, uid, ids, name, args, context=None):
- res = {}
- for page in self.browse(cr, uid, ids, context=context):
+ def _get_display_content(self):
+ for page in self:
if page.type == "category":
- content = self._get_page_index(cr, uid, page, link=False)
+ display_content = self._get_page_index(page, link=False)
else:
- content = page.content
- res[page.id] = content
- return res
-
- _columns = {
- 'name': fields.char('Title', required=True),
- 'type': fields.selection([('content', 'Content'),
- ('category', 'Category')],
- 'Type', help="Page type"),
- 'parent_id': fields.many2one('document.page', 'Category',
- domain=[('type', '=', 'category')]),
- 'child_ids': fields.one2many('document.page', 'parent_id', 'Children'),
- 'content': fields.text("Content"),
- 'display_content': fields.function(_get_display_content,
- string='Displayed Content',
- type='text'),
- 'history_ids': fields.one2many('document.page.history', 'page_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, readonly=True),
- }
- _defaults = {
- 'type': 'content',
- }
+ display_content = page.content
+ page.display_content = display_content
def onchange_parent_id(self, cr, uid, ids, parent_id, content,
context=None):
@@ -112,19 +149,17 @@ class document_page(osv.osv):
return result
-class document_page_history(osv.osv):
+class document_page_history(models.Model):
_name = "document.page.history"
_description = "Document Page History"
_order = 'id DESC'
_rec_name = "create_date"
- _columns = {
- 'page_id': fields.many2one('document.page', 'Page'),
- 'summary': fields.char('Summary', size=256, select=True),
- 'content': fields.text("Content"),
- 'create_date': fields.datetime("Date"),
- 'create_uid': fields.many2one('res.users', "Modified By"),
- }
+ page_id = fields.Many2one('document.page', 'Page')
+ summary = fields.Char('Summary', size=256, select=True)
+ content = fields.Text("Content")
+ create_date = fields.Datetime("Date")
+ create_uid = fields.Many2one('res.users', "Modified By")
def getDiff(self, cr, uid, v1, v2, context=None):
history_pool = self.pool.get('document.page.history')
@@ -136,8 +171,9 @@ class document_page_history(osv.osv):
if text2:
line2 = text2.splitlines(1)
if (not line1 and not line2) or (line1 == line2):
- raise osv.except_osv(_('Warning!'),
- _('There are no changes in revisions.'))
+ raise exceptions.Warning(
+ _('There are no changes in revisions.')
+ )
diff = difflib.HtmlDiff()
return diff.make_table(line1, line2, "Revision-%s" % (v1),
"Revision-%s" % (v2), context=True)
diff --git a/document_page/document_page_view.xml b/document_page/document_page_view.xml
index 2ffc9059..f05a2d52 100644
--- a/document_page/document_page_view.xml
+++ b/document_page/document_page_view.xml
@@ -1,8 +1,13 @@