Skip to content

Commit

Permalink
[MIG] document_page: Migration to 18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jdoutreloux committed Nov 7, 2024
1 parent adbf5ac commit c4518fd
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 38 deletions.
10 changes: 5 additions & 5 deletions document_page/models/document_page.py
Original file line number Diff line number Diff line change
@@ -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


Expand Down Expand Up @@ -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."""
Expand Down Expand Up @@ -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)
8 changes: 2 additions & 6 deletions document_page/models/document_page_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import difflib

from odoo import _, api, fields, models
from odoo import api, fields, models


class DocumentPageHistory(models.Model):
Expand Down Expand Up @@ -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(
Expand All @@ -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:
Expand Down
21 changes: 11 additions & 10 deletions document_page/views/document_page.xml
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
<?xml version="1.0" ?>
<odoo>
<!-- wiki tree view -->
<!-- wiki list view -->
<record id="view_wiki_tree_children" model="ir.ui.view">
<field name="name">document.page.tree</field>
<field name="name">document.page.list</field>
<field name="model">document.page</field>
<field name="priority">100</field>
<field name="arch" type="xml">
<tree>
<list>
<field name="name" />
<field name="content_uid" />
<field name="content_date" />
</tree>
</list>
</field>
</record>
<!-- wiki list view -->
<record id="view_wiki_tree" model="ir.ui.view">
<field name="name">document.page.list</field>
<field name="model">document.page</field>
<field name="arch" type="xml">
<tree>
<list>
<field name="name" />
<field name="parent_id" />
<field name="company_id" groups="base.group_multi_company" />
<field name="create_uid" column_invisible="1" />
<field name="content_uid" />
<field name="content_date" />
</tree>
</list>
</field>
</record>
<!-- wiki Form view -->
Expand Down Expand Up @@ -94,13 +94,13 @@
</page>
<page name="history" string="History">
<field name="history_ids">
<tree>
<list>
<field name="id" />
<field name="create_date" />
<field name="name" />
<field name="summary" />
<field name="create_uid" />
</tree>
</list>
</field>
</page>
</notebook>
Expand Down Expand Up @@ -178,10 +178,11 @@
<!-- page action -->
<record id="action_page" model="ir.actions.act_window">
<field name="name">Pages</field>
<field name="path">document_pages</field>
<field name="res_model">document.page</field>
<field name="domain">[('type','=','content')]</field>
<field name="context">{'default_type': 'content'}</field>
<field name="view_mode">tree,form</field>
<field name="view_mode">list,form</field>
<field name="view_id" ref="view_wiki_tree" />
<field name="search_view_id" ref="view_wiki_filter" />
<field name="help" type="html">
Expand All @@ -192,7 +193,7 @@
</record>
<record id="action_page_view_tree" model="ir.actions.act_window.view">
<field name="sequence" eval="0" />
<field name="view_mode">tree</field>
<field name="view_mode">list</field>
<field name="view_id" ref="view_wiki_tree" />
<field name="act_window_id" ref="action_page" />
</record>
Expand Down
16 changes: 7 additions & 9 deletions document_page/views/document_page_category.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,25 +48,22 @@
</page>
</notebook>
</sheet>
<div class="oe_chatter">
<field name="message_follower_ids" widget="mail_followers" />
<field name="message_ids" widget="mail_thread" />
</div>
<chatter />
</form>
</field>
</record>
<record id="view_category_tree" model="ir.ui.view">
<field name="name">document.page.category.tree</field>
<field name="name">document.page.category.list</field>
<field name="model">document.page</field>
<field name="arch" type="xml">
<tree>
<list>
<field name="name" />
<field name="parent_id" />
<field name="create_uid" column_invisible="1" />
<field name="write_uid" />
<field name="write_date" />
<field name="company_id" groups="base.group_multi_company" />
</tree>
</list>
</field>
</record>
<record id="view_document_category_filter" model="ir.ui.view">
Expand Down Expand Up @@ -106,16 +103,17 @@
<!-- Category Action -->
<record id="action_category" model="ir.actions.act_window">
<field name="name">Category</field>
<field name="path">document_page_categories</field>
<field name="res_model">document.page</field>
<field name="domain">[('type','=','category')]</field>
<field name="context">{'default_type': 'category'}</field>
<field name="view_mode">tree,form</field>
<field name="view_mode">list,form</field>
<field name="view_id" ref="view_category_tree" />
<field name="search_view_id" ref="view_document_category_filter" />
</record>
<record id="action_category_view_tree" model="ir.actions.act_window.view">
<field name="sequence" eval="0" />
<field name="view_mode">tree</field>
<field name="view_mode">list</field>
<field name="view_id" ref="view_category_tree" />
<field name="act_window_id" ref="action_category" />
</record>
Expand Down
12 changes: 7 additions & 5 deletions document_page/views/document_page_history.xml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<?xml version="1.0" ?>
<odoo>
<!-- History Tree view -->
<!-- History List view -->
<record model="ir.ui.view" id="view_wiki_history_tree">
<field name="name">document.page.history.tree</field>
<field name="name">document.page.history.list</field>
<field name="model">document.page.history</field>
<field name="arch" type="xml">
<tree>
<list>
<field name="id" />
<field name="page_id" />
<field name="name" />
<field name="summary" />
<field name="create_uid" />
<field name="create_date" />
</tree>
</list>
</field>
</record>

Expand Down Expand Up @@ -81,8 +81,9 @@
<!-- History Action -->
<record model="ir.actions.act_window" id="action_history">
<field name="name">Page history</field>
<field name="path">document_page_history_all</field>
<field name="res_model">document.page.history</field>
<field name="view_mode">tree,form</field>
<field name="view_mode">list,form</field>
</record>

<menuitem
Expand All @@ -96,6 +97,7 @@

<record id="action_related_page_history" model="ir.actions.act_window">
<field name="name">Page History</field>
<field name="path">document_page_history</field>
<field name="res_model">document.page.history</field>
<field name="domain">[('page_id','=',active_id)]</field>
<field
Expand Down
2 changes: 1 addition & 1 deletion document_page/wizard/document_page_create_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def document_page_menu_create(self):
view_id = obj_model_data._xmlid_to_res_id("document_page.view_wiki_menu_form")
value = {
"name": "Document Page",
"view_mode": "form,tree",
"view_mode": "form,list",
"res_model": "document.page",
"view_id": view_id,
"type": "ir.actions.act_window",
Expand Down
4 changes: 2 additions & 2 deletions document_page/wizard/document_page_show_diff.py
Original file line number Diff line number Diff line change
@@ -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 _, fields, models
from odoo import fields, models
from odoo.exceptions import UserError


Expand All @@ -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)

0 comments on commit c4518fd

Please sign in to comment.