From c4518fd2ce32b76296cb189e438b84ceaecdc391 Mon Sep 17 00:00:00 2001 From: Justine Doutreloux Date: Thu, 7 Nov 2024 17:14:58 +0100 Subject: [PATCH] [MIG] document_page: Migration to 18.0 --- document_page/models/document_page.py | 10 ++++----- document_page/models/document_page_history.py | 8 ++----- document_page/views/document_page.xml | 21 ++++++++++--------- .../views/document_page_category.xml | 16 +++++++------- document_page/views/document_page_history.xml | 12 ++++++----- .../wizard/document_page_create_menu.py | 2 +- .../wizard/document_page_show_diff.py | 4 ++-- 7 files changed, 35 insertions(+), 38 deletions(-) diff --git a/document_page/models/document_page.py b/document_page/models/document_page.py index a1a7ca039c7..d5542feeee2 100644 --- a/document_page/models/document_page.py +++ b/document_page/models/document_page.py @@ -1,7 +1,7 @@ # Copyright (C) 2004-2010 Tiny SPRL (). # 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 @@ def _compute_backend_url(self): @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 @@ def unlink(self): 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) diff --git a/document_page/models/document_page_history.py b/document_page/models/document_page_history.py index 35ddb3922ff..b2bf80a6506 100644 --- a/document_page/models/document_page_history.py +++ b/document_page/models/document_page_history.py @@ -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 @@ def _get_diff(self, v1, v2): 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 @@ def _get_diff(self, v1, v2): 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: diff --git a/document_page/views/document_page.xml b/document_page/views/document_page.xml index 94baf4ffc65..3d14a24a264 100644 --- a/document_page/views/document_page.xml +++ b/document_page/views/document_page.xml @@ -1,16 +1,16 @@ - + - document.page.tree + document.page.list document.page 100 - + - + @@ -18,14 +18,14 @@ document.page.list document.page - + - + @@ -94,13 +94,13 @@ - + - + @@ -178,10 +178,11 @@ Pages + document_pages document.page [('type','=','content')] {'default_type': 'content'} - tree,form + list,form @@ -192,7 +193,7 @@ - tree + list diff --git a/document_page/views/document_page_category.xml b/document_page/views/document_page_category.xml index 0ea59d7c5f8..345a3865848 100644 --- a/document_page/views/document_page_category.xml +++ b/document_page/views/document_page_category.xml @@ -48,25 +48,22 @@ -
- - -
+ - document.page.category.tree + document.page.category.list document.page - + - + @@ -106,16 +103,17 @@ Category + document_page_categories document.page [('type','=','category')] {'default_type': 'category'} - tree,form + list,form - tree + list diff --git a/document_page/views/document_page_history.xml b/document_page/views/document_page_history.xml index 12dc52f2f17..c8353acfa68 100644 --- a/document_page/views/document_page_history.xml +++ b/document_page/views/document_page_history.xml @@ -1,18 +1,18 @@ - + - document.page.history.tree + document.page.history.list document.page.history - + - + @@ -81,8 +81,9 @@ Page history + document_page_history_all document.page.history - tree,form + list,form Page History + document_page_history document.page.history [('page_id','=',active_id)] ). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import _, fields, models +from odoo import fields, models from odoo.exceptions import UserError @@ -24,7 +24,7 @@ def _get_diff(self): elif len(ids) == 1: diff = history.browse(ids[0]).diff else: - raise UserError(_("Select one or maximum two history revisions!")) + raise UserError(self.env._("Select one or maximum two history revisions!")) return diff diff = fields.Html(readonly=True, default=_get_diff)