mirror of
https://github.com/OCA/knowledge.git
synced 2025-12-21 21:02:19 -06:00
[MIG] document_page: Migration to 18.0
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import _, api, fields, models
|
||||
from odoo import api, fields, models
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
|
||||
@@ -111,8 +111,8 @@ class DocumentPage(models.Model):
|
||||
|
||||
@api.constrains("parent_id")
|
||||
def _check_parent_id(self):
|
||||
if not self._check_recursion():
|
||||
raise ValidationError(_("You cannot create recursive categories."))
|
||||
if self._has_cycle():
|
||||
raise ValidationError(self.env._("You cannot create recursive categories."))
|
||||
|
||||
def _get_page_index(self, link=True):
|
||||
"""Return the index of a document."""
|
||||
@@ -184,9 +184,9 @@ class DocumentPage(models.Model):
|
||||
def copy(self, default=None):
|
||||
default = dict(
|
||||
default or {},
|
||||
name=_("%s (copy)") % self.name,
|
||||
name=self.env._("%s (copy)") % self.name,
|
||||
content=self.content,
|
||||
draft_name="1.0",
|
||||
draft_summary=_("summary"),
|
||||
draft_summary=self.env._("summary"),
|
||||
)
|
||||
return super().copy(default=default)
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
import difflib
|
||||
|
||||
from odoo import _, api, fields, models
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class DocumentPageHistory(models.Model):
|
||||
@@ -55,7 +55,7 @@ class DocumentPageHistory(models.Model):
|
||||
line1 = text1.splitlines(True)
|
||||
line2 = text2.splitlines(True)
|
||||
if line1 == line2:
|
||||
return _("There are no changes in revisions.")
|
||||
return self.env._("There are no changes in revisions.")
|
||||
else:
|
||||
diff = difflib.HtmlDiff()
|
||||
return diff.make_table(
|
||||
@@ -66,10 +66,6 @@ class DocumentPageHistory(models.Model):
|
||||
context=True,
|
||||
)
|
||||
|
||||
# TODO: Replace for _compute_display_name
|
||||
def name_get(self):
|
||||
return [(rec.id, "%s #%i" % (rec.page_id.name, rec.id)) for rec in self]
|
||||
|
||||
@api.depends("page_id")
|
||||
def _compute_display_name(self):
|
||||
for rec in self:
|
||||
|
||||
Reference in New Issue
Block a user