diff --git a/document_page/__init__.py b/document_page/__init__.py
index a5aa017f..d11fab84 100644
--- a/document_page/__init__.py
+++ b/document_page/__init__.py
@@ -18,8 +18,5 @@
# along with this program. If not, see .
#
##############################################################################
-
-from . import (
- document_page,
- wizard
- )
+from . import document_page
+from . import wizard
diff --git a/document_page/__openerp__.py b/document_page/__openerp__.py
index 3aba6e55..48e0d60c 100644
--- a/document_page/__openerp__.py
+++ b/document_page/__openerp__.py
@@ -38,8 +38,12 @@ Web pages
'security/document_page_security.xml',
'security/ir.model.access.csv',
],
- 'demo': ['document_page_demo.xml'],
- 'test': ['test/document_page_test00.yml'],
+ 'demo': [
+ 'document_page_demo.xml'
+ ],
+ 'test': [
+ 'test/document_page_test00.yml'
+ ],
'installable': True,
'auto_install': False,
'images': [],
diff --git a/document_page/document_page.py b/document_page/document_page.py
index bcd10742..7aba083d 100644
--- a/document_page/document_page.py
+++ b/document_page/document_page.py
@@ -18,67 +18,104 @@
# along with this program. If not, see .
#
##############################################################################
-
-from openerp.osv import fields, osv
-from openerp.tools.translate import _
+from openerp import models, fields, _
+from openerp import exceptions
+# , fields, api, _
import difflib
-class document_page(osv.osv):
+class document_page(models.Model):
_name = "document.page"
_description = "Document Page"
_order = 'name'
- def _get_page_index(self, cr, uid, page, link=True):
+ name = fields.Char('Title', required=True)
+
+ type = fields.Selection(
+ [('content', 'Content'), ('category', 'Category')],
+ 'Type',
+ help="Page type",
+ default="content"
+ )
+
+ 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.Text(
+ string='Displayed Content',
+ compute='_get_display_content'
+ )
+
+ 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
+ )
+
+ def _get_page_index(self, page, link=True):
index = []
for subpage in page.child_ids:
- index += ["
" + self._get_page_index(cr, uid, subpage) +
+ index += ["" + self._get_page_index(subpage) +
""]
r = ''
if link:
r = '%s' % (page.id, page.name)
+
if index:
r += ""
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 @@
-
-
+
+
+
@@ -18,6 +23,7 @@
+
document.page.list
@@ -32,6 +38,7 @@
+
document.page.form
@@ -50,34 +57,52 @@
+
that will be used as a content template for all new page of this category.
-
+
-
+
+
document.page.search
document.page
-
+
-
-
-
+
+
+
+
+
Pages
@@ -94,7 +119,13 @@
-
+
+
+
Category
document.page
@@ -105,7 +136,11 @@
-
+
@@ -134,6 +169,7 @@
+
Page history
@@ -141,7 +177,14 @@
form
tree,form
-
+
+
+
- .
#
##############################################################################
-
-import document_page_create_menu
-import document_page_show_diff
+from . import document_page_create_menu
+from . import document_page_show_diff
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/document_page/wizard/document_page_create_menu_view.xml b/document_page/wizard/document_page_create_menu_view.xml
index e4647179..858aa0ed 100644
--- a/document_page/wizard/document_page_create_menu_view.xml
+++ b/document_page/wizard/document_page_create_menu_view.xml
@@ -12,15 +12,23 @@
+
+
-