[MIG] document_page: Migration to 12.0

This commit is contained in:
mreficent
2019-03-12 13:23:37 +01:00
committed by Justine Doutreloux
parent fc22ca50fb
commit 792991fba3
25 changed files with 51 additions and 60 deletions

View File

@@ -1,4 +1,3 @@
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import document_page

View File

@@ -14,28 +14,23 @@ class DocumentPage(models.Model):
_order = 'name'
name = fields.Char('Title', required=True)
type = fields.Selection(
[('content', 'Content'), ('category', 'Category')],
'Type',
help="Page type",
default="content"
)
active = fields.Boolean(default=True)
parent_id = fields.Many2one(
'document.page',
'Category',
domain=[('type', '=', 'category')]
)
child_ids = fields.One2many(
'document.page',
'parent_id',
'Children'
)
content = fields.Text(
"Content",
compute='_compute_content',
@@ -65,7 +60,6 @@ class DocumentPage(models.Model):
help="Template that will be used as a content template "
"for all new page of this category.",
)
history_head = fields.Many2one(
'document.page.history',
'HEAD',
@@ -73,7 +67,6 @@ class DocumentPage(models.Model):
store=True,
auto_join=True,
)
history_ids = fields.One2many(
'document.page.history',
'page_id',
@@ -81,13 +74,11 @@ class DocumentPage(models.Model):
order='create_date DESC',
readonly=True,
)
menu_id = fields.Many2one(
'ir.ui.menu',
"Menu",
readonly=True,
)
content_date = fields.Datetime(
'Last Contribution Date',
related='history_head.create_date',
@@ -95,7 +86,6 @@ class DocumentPage(models.Model):
index=True,
readonly=True,
)
content_uid = fields.Many2one(
'res.users',
'Last Contributor',
@@ -104,7 +94,6 @@ class DocumentPage(models.Model):
index=True,
readonly=True,
)
company_id = fields.Many2one(
'res.company',
'Company',

View File

@@ -40,12 +40,12 @@ class DocumentPageHistory(models.Model):
limit=1,
order='create_date DESC')
if prev:
rec.diff = self.getDiff(prev.id, rec.id)
rec.diff = self._get_diff(prev.id, rec.id)
else:
rec.diff = self.getDiff(False, rec.id)
rec.diff = self._get_diff(False, rec.id)
@api.model
def getDiff(self, v1, v2):
def _get_diff(self, v1, v2):
"""Return the difference between two version of document version."""
text1 = v1 and self.browse(v1).content or ''
text2 = v2 and self.browse(v2).content or ''
@@ -53,8 +53,8 @@ class DocumentPageHistory(models.Model):
# TODO: consider using a beautify library directly on the content
text1 = text1.replace('</p><p>', '</p>\r\n<p>')
text2 = text2.replace('</p><p>', '</p>\r\n<p>')
line1 = text1.splitlines(1)
line2 = text2.splitlines(1)
line1 = text1.splitlines(True)
line2 = text2.splitlines(True)
if line1 == line2:
return _('There are no changes in revisions.')
else: