mirror of
https://github.com/OCA/knowledge.git
synced 2025-12-20 04:12:18 -06:00
@@ -1,7 +1,3 @@
|
||||
.. image:: https://odoo-community.org/readme-banner-image
|
||||
:target: https://odoo-community.org/get-involved?utm_source=readme
|
||||
:alt: Odoo Community Association
|
||||
|
||||
=============
|
||||
Document Page
|
||||
=============
|
||||
@@ -17,7 +13,7 @@ Document Page
|
||||
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
|
||||
:target: https://odoo-community.org/page/development-status
|
||||
:alt: Beta
|
||||
.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png
|
||||
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
|
||||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
|
||||
:alt: License: AGPL-3
|
||||
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fknowledge-lightgray.png?logo=github
|
||||
@@ -61,6 +57,12 @@ To use this module, you need to:
|
||||
- Click on Pages to create pages and select the previous category to use
|
||||
the template
|
||||
|
||||
Improve diff of history
|
||||
-----------------------
|
||||
|
||||
If you want to improve how history is shown, you can install html_diff
|
||||
python library. A new comparison method will be installed.
|
||||
|
||||
Bug Tracker
|
||||
===========
|
||||
|
||||
@@ -83,23 +85,34 @@ Contributors
|
||||
------------
|
||||
|
||||
- Gervais Naoussi <gervaisnaoussi@gmail.com>
|
||||
|
||||
- Maxime Chambreuil <mchambreuil@ursainfosystems.com>
|
||||
|
||||
- Iván Todorovich <ivan.todorovich@gmail.com>
|
||||
|
||||
- Jose Maria Alzaga <jose.alzaga@aselcis.com>
|
||||
|
||||
- Lois Rilo <lois.rilo@forgeflow.com>
|
||||
|
||||
- Simone Orsi <simone.orsi@camptocamp.com>
|
||||
|
||||
- `Tecnativa <https://www.tecnativa.com>`__:
|
||||
|
||||
- Ernesto Tejeda
|
||||
- Víctor Martínez
|
||||
|
||||
Trobz
|
||||
- Trobz
|
||||
|
||||
- Dung Tran <dungtd@trobz.com>
|
||||
|
||||
- Dung Tran <dungtd@trobz.com>
|
||||
- `Sygel <https://www.sygel.es>`__:
|
||||
|
||||
- Ángel García de la Chica Herrera
|
||||
|
||||
- `Dixmit <https://www.dixmit.com>`__:
|
||||
|
||||
- Enric Tobella
|
||||
|
||||
Other credits
|
||||
-------------
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
],
|
||||
"website": "https://github.com/OCA/knowledge",
|
||||
"license": "AGPL-3",
|
||||
"depends": ["mail", "document_knowledge"],
|
||||
"depends": ["mail", "document_knowledge", "web_editor"],
|
||||
"data": [
|
||||
"security/document_page_security.xml",
|
||||
"security/ir.model.access.csv",
|
||||
@@ -30,6 +30,9 @@
|
||||
],
|
||||
"demo": ["demo/document_page.xml"],
|
||||
"assets": {
|
||||
"web._assets_primary_variables": [
|
||||
"document_page/static/src/**/document_page_variables.scss",
|
||||
],
|
||||
"web.assets_backend": [
|
||||
"document_page/static/src/scss/document_page.scss",
|
||||
"document_page/static/src/js/document_page_kanban_controller.esm.js",
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
import difflib
|
||||
|
||||
from odoo import api, fields, models
|
||||
|
||||
from odoo.addons.web_editor.models.diff_utils import (
|
||||
generate_comparison,
|
||||
)
|
||||
|
||||
|
||||
class DocumentPageHistory(models.Model):
|
||||
"""This model is necessary to manage a document history."""
|
||||
@@ -17,7 +20,7 @@ class DocumentPageHistory(models.Model):
|
||||
name = fields.Char(index=True)
|
||||
summary = fields.Char(index=True)
|
||||
content = fields.Html(sanitize=False)
|
||||
diff = fields.Html(compute="_compute_diff")
|
||||
diff = fields.Html(compute="_compute_diff", sanitize_tags=False)
|
||||
|
||||
company_id = fields.Many2one(
|
||||
"res.company",
|
||||
@@ -43,28 +46,10 @@ class DocumentPageHistory(models.Model):
|
||||
)
|
||||
rec.diff = self._get_diff(prev.id, rec.id)
|
||||
|
||||
@api.model
|
||||
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 ""
|
||||
# Include line breaks to make it more readable
|
||||
# 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(True)
|
||||
line2 = text2.splitlines(True)
|
||||
if line1 == line2:
|
||||
return self.env._("There are no changes in revisions.")
|
||||
else:
|
||||
diff = difflib.HtmlDiff()
|
||||
return diff.make_table(
|
||||
line1,
|
||||
line2,
|
||||
f"Revision-{v1}",
|
||||
f"Revision-{v2}",
|
||||
context=True,
|
||||
)
|
||||
return generate_comparison(text1, text2)
|
||||
|
||||
@api.depends("page_id")
|
||||
def _compute_display_name(self):
|
||||
|
||||
@@ -8,8 +8,11 @@
|
||||
- Ernesto Tejeda
|
||||
- Víctor Martínez
|
||||
|
||||
Trobz
|
||||
- Trobz
|
||||
- Dung Tran \<<dungtd@trobz.com>\>
|
||||
|
||||
- Dung Tran \<<dungtd@trobz.com>\>
|
||||
- [Sygel](https://www.sygel.es):
|
||||
- Ángel García de la Chica Herrera
|
||||
|
||||
- [Dixmit](https://www.dixmit.com):
|
||||
- Enric Tobella
|
||||
|
||||
@@ -5,3 +5,8 @@ To use this module, you need to:
|
||||
the template
|
||||
- Click on Pages to create pages and select the previous category to use
|
||||
the template
|
||||
|
||||
## Improve diff of history
|
||||
|
||||
If you want to improve how history is shown, you can install html_diff python library.
|
||||
A new comparison method will be installed.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
|
||||
<title>README.rst</title>
|
||||
<title>Document Page</title>
|
||||
<style type="text/css">
|
||||
|
||||
/*
|
||||
@@ -360,49 +360,47 @@ ul.auto-toc {
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="document">
|
||||
<div class="document" id="document-page">
|
||||
<h1 class="title">Document Page</h1>
|
||||
|
||||
|
||||
<a class="reference external image-reference" href="https://odoo-community.org/get-involved?utm_source=readme">
|
||||
<img alt="Odoo Community Association" src="https://odoo-community.org/readme-banner-image" />
|
||||
</a>
|
||||
<div class="section" id="document-page">
|
||||
<h1>Document Page</h1>
|
||||
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!! This file is generated by oca-gen-addon-readme !!
|
||||
!! changes will be overwritten. !!
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!! source digest: sha256:029a3933b3eea6e056988a1f6fb36f83a4539b5a7d32e7bef7b60dfc3f871c98
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||||
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/knowledge/tree/18.0/document_page"><img alt="OCA/knowledge" src="https://img.shields.io/badge/github-OCA%2Fknowledge-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/knowledge-18-0/knowledge-18-0-document_page"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/knowledge&target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
|
||||
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/knowledge/tree/18.0/document_page"><img alt="OCA/knowledge" src="https://img.shields.io/badge/github-OCA%2Fknowledge-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/knowledge-18-0/knowledge-18-0-document_page"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/knowledge&target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
|
||||
<p>This module allows you to write web pages for internal documentation.</p>
|
||||
<p><strong>Table of contents</strong></p>
|
||||
<div class="contents local topic" id="contents">
|
||||
<ul class="simple">
|
||||
<li><a class="reference internal" href="#installation" id="toc-entry-1">Installation</a></li>
|
||||
<li><a class="reference internal" href="#configuration" id="toc-entry-2">Configuration</a></li>
|
||||
<li><a class="reference internal" href="#usage" id="toc-entry-3">Usage</a></li>
|
||||
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-4">Bug Tracker</a></li>
|
||||
<li><a class="reference internal" href="#credits" id="toc-entry-5">Credits</a><ul>
|
||||
<li><a class="reference internal" href="#authors" id="toc-entry-6">Authors</a></li>
|
||||
<li><a class="reference internal" href="#contributors" id="toc-entry-7">Contributors</a></li>
|
||||
<li><a class="reference internal" href="#other-credits" id="toc-entry-8">Other credits</a></li>
|
||||
<li><a class="reference internal" href="#maintainers" id="toc-entry-9">Maintainers</a></li>
|
||||
<li><a class="reference internal" href="#usage" id="toc-entry-3">Usage</a><ul>
|
||||
<li><a class="reference internal" href="#improve-diff-of-history" id="toc-entry-4">Improve diff of history</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-5">Bug Tracker</a></li>
|
||||
<li><a class="reference internal" href="#credits" id="toc-entry-6">Credits</a><ul>
|
||||
<li><a class="reference internal" href="#authors" id="toc-entry-7">Authors</a></li>
|
||||
<li><a class="reference internal" href="#contributors" id="toc-entry-8">Contributors</a></li>
|
||||
<li><a class="reference internal" href="#other-credits" id="toc-entry-9">Other credits</a></li>
|
||||
<li><a class="reference internal" href="#maintainers" id="toc-entry-10">Maintainers</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="installation">
|
||||
<h2><a class="toc-backref" href="#toc-entry-1">Installation</a></h2>
|
||||
<h1><a class="toc-backref" href="#toc-entry-1">Installation</a></h1>
|
||||
<p>This module depends on module knowledge. So make sure to have it in your
|
||||
addons list.</p>
|
||||
</div>
|
||||
<div class="section" id="configuration">
|
||||
<h2><a class="toc-backref" href="#toc-entry-2">Configuration</a></h2>
|
||||
<h1><a class="toc-backref" href="#toc-entry-2">Configuration</a></h1>
|
||||
<p>No configuration required.</p>
|
||||
</div>
|
||||
<div class="section" id="usage">
|
||||
<h2><a class="toc-backref" href="#toc-entry-3">Usage</a></h2>
|
||||
<h1><a class="toc-backref" href="#toc-entry-3">Usage</a></h1>
|
||||
<p>To use this module, you need to:</p>
|
||||
<ul class="simple">
|
||||
<li>Go to Knowledge menu</li>
|
||||
@@ -411,9 +409,14 @@ the template</li>
|
||||
<li>Click on Pages to create pages and select the previous category to use
|
||||
the template</li>
|
||||
</ul>
|
||||
<div class="section" id="improve-diff-of-history">
|
||||
<h2><a class="toc-backref" href="#toc-entry-4">Improve diff of history</a></h2>
|
||||
<p>If you want to improve how history is shown, you can install html_diff
|
||||
python library. A new comparison method will be installed.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="bug-tracker">
|
||||
<h2><a class="toc-backref" href="#toc-entry-4">Bug Tracker</a></h2>
|
||||
<h1><a class="toc-backref" href="#toc-entry-5">Bug Tracker</a></h1>
|
||||
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/knowledge/issues">GitHub Issues</a>.
|
||||
In case of trouble, please check there if your issue has already been reported.
|
||||
If you spotted it first, help us to smash it by providing a detailed and welcomed
|
||||
@@ -421,15 +424,15 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
|
||||
<p>Do not contact contributors directly about support or help with technical issues.</p>
|
||||
</div>
|
||||
<div class="section" id="credits">
|
||||
<h2><a class="toc-backref" href="#toc-entry-5">Credits</a></h2>
|
||||
<h1><a class="toc-backref" href="#toc-entry-6">Credits</a></h1>
|
||||
<div class="section" id="authors">
|
||||
<h3><a class="toc-backref" href="#toc-entry-6">Authors</a></h3>
|
||||
<h2><a class="toc-backref" href="#toc-entry-7">Authors</a></h2>
|
||||
<ul class="simple">
|
||||
<li>OpenERP SA</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="contributors">
|
||||
<h3><a class="toc-backref" href="#toc-entry-7">Contributors</a></h3>
|
||||
<h2><a class="toc-backref" href="#toc-entry-8">Contributors</a></h2>
|
||||
<ul class="simple">
|
||||
<li>Gervais Naoussi <<a class="reference external" href="mailto:gervaisnaoussi@gmail.com">gervaisnaoussi@gmail.com</a>></li>
|
||||
<li>Maxime Chambreuil <<a class="reference external" href="mailto:mchambreuil@ursainfosystems.com">mchambreuil@ursainfosystems.com</a>></li>
|
||||
@@ -442,18 +445,22 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
|
||||
<li>Víctor Martínez</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
<p>Trobz</p>
|
||||
<ul class="simple">
|
||||
<li>Trobz<ul>
|
||||
<li>Dung Tran <<a class="reference external" href="mailto:dungtd@trobz.com">dungtd@trobz.com</a>></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference external" href="https://www.sygel.es">Sygel</a>:<ul>
|
||||
<li>Ángel García de la Chica Herrera</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference external" href="https://www.dixmit.com">Dixmit</a>:<ul>
|
||||
<li>Enric Tobella</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="other-credits">
|
||||
<h3><a class="toc-backref" href="#toc-entry-8">Other credits</a></h3>
|
||||
<h2><a class="toc-backref" href="#toc-entry-9">Other credits</a></h2>
|
||||
<p>The development of this module has been financially supported by:</p>
|
||||
<ul class="simple">
|
||||
<li>Odoo SA <<a class="reference external" href="http://www.odoo.com">http://www.odoo.com</a>></li>
|
||||
@@ -462,7 +469,7 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="maintainers">
|
||||
<h3><a class="toc-backref" href="#toc-entry-9">Maintainers</a></h3>
|
||||
<h2><a class="toc-backref" href="#toc-entry-10">Maintainers</a></h2>
|
||||
<p>This module is maintained by the OCA.</p>
|
||||
<a class="reference external image-reference" href="https://odoo-community.org">
|
||||
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
|
||||
@@ -475,6 +482,5 @@ promote its widespread use.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,28 +1,40 @@
|
||||
table.diff {
|
||||
font-family: Courier;
|
||||
border: medium;
|
||||
.o_document_page_diff {
|
||||
table.diff {
|
||||
font-family: Courier;
|
||||
border: medium;
|
||||
|
||||
.diff_header {
|
||||
background-color: #e0e0e0;
|
||||
.diff_header {
|
||||
background-color: $o_document_page_diff_header_background;
|
||||
}
|
||||
|
||||
td.diff_header {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.diff_next {
|
||||
background-color: $o_document_page_diff_next_background;
|
||||
}
|
||||
|
||||
.diff_add {
|
||||
background-color: $o_document_page_diff_add_background;
|
||||
}
|
||||
|
||||
.diff_chg {
|
||||
background-color: $o_document_page_diff_change_background;
|
||||
}
|
||||
|
||||
.diff_sub {
|
||||
background-color: $o_document_page_diff_subtract_background;
|
||||
}
|
||||
}
|
||||
|
||||
td.diff_header {
|
||||
text-align: right;
|
||||
removed {
|
||||
display: inline;
|
||||
text-decoration: line-through;
|
||||
opacity: 0.5;
|
||||
background-color: $o_document_page_diff_subtract_background;
|
||||
}
|
||||
|
||||
.diff_next {
|
||||
background-color: #c0c0c0;
|
||||
}
|
||||
|
||||
.diff_add {
|
||||
background-color: #aaffaa;
|
||||
}
|
||||
|
||||
.diff_chg {
|
||||
background-color: #ffff77;
|
||||
}
|
||||
|
||||
.diff_sub {
|
||||
background-color: #ffaaaa;
|
||||
added {
|
||||
display: inline;
|
||||
background-color: $o_document_page_diff_add_background;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
$o_document_page_diff_header_background: #e0e0e0;
|
||||
$o_document_page_diff_next_background: #c0c0c0;
|
||||
$o_document_page_diff_add_background: #aaffaa;
|
||||
$o_document_page_diff_change_background: #ffff77;
|
||||
$o_document_page_diff_subtract_background: #ffaaaa;
|
||||
@@ -31,12 +31,16 @@ class TestDocumentPage(common.TransactionCase):
|
||||
self.assertEqual(page.content, self.category1.template)
|
||||
|
||||
def test_page_history_diff(self):
|
||||
page = self.page_obj.create({"name": "Test Page 3", "content": "Test content"})
|
||||
page.content = "New content"
|
||||
page = self.page_obj.create(
|
||||
{"name": "Test Page 3", "content": "<div>Test content</div>"}
|
||||
)
|
||||
page.content = "<div>New content</div>"
|
||||
self.assertIsNotNone(page.history_ids[0].diff)
|
||||
|
||||
def test_page_link(self):
|
||||
page = self.page_obj.create({"name": "Test Page 3", "content": "Test content"})
|
||||
page = self.page_obj.create(
|
||||
{"name": "Test Page 3", "content": "<div>Test content</div>"}
|
||||
)
|
||||
self.assertEqual(
|
||||
page.backend_url,
|
||||
f"/web#id={page.id}&model=document.page&view_type=form",
|
||||
@@ -49,7 +53,9 @@ class TestDocumentPage(common.TransactionCase):
|
||||
)
|
||||
|
||||
def test_page_copy(self):
|
||||
page = self.page_obj.create({"name": "Test Page 3", "content": "Test content"})
|
||||
page = self.page_obj.create(
|
||||
{"name": "Test Page 3", "content": "<div>Test content</div>"}
|
||||
)
|
||||
page_copy = page.copy()
|
||||
self.assertEqual(page_copy.name, page.name + " (copy)")
|
||||
self.assertEqual(page_copy.content, page.content)
|
||||
|
||||
@@ -6,14 +6,15 @@ class TestDocumentPageHistory(common.TransactionCase):
|
||||
|
||||
def test_page_history_demo_page1(self):
|
||||
"""Test page history demo page1."""
|
||||
page = self.env.ref("document_page.demo_page1")
|
||||
page.content = "Test content updated"
|
||||
page = self.env["document.page"].create(
|
||||
{
|
||||
"name": "Test Page",
|
||||
"content": "<div>Initial content</div>",
|
||||
}
|
||||
)
|
||||
page.content = "<div>Test content updated</div>"
|
||||
history_document = self.env["document.page.history"]
|
||||
history_pages = history_document.search([("page_id", "=", page.id)])
|
||||
active_ids = [i.id for i in history_pages]
|
||||
|
||||
result = history_document._get_diff(active_ids[0], active_ids[0])
|
||||
self.assertEqual(result, "There are no changes in revisions.")
|
||||
|
||||
result = history_document._get_diff(active_ids[0], active_ids[1])
|
||||
self.assertNotEqual(result, "There are no changes in revisions.")
|
||||
self.assertEqual(result, page.content)
|
||||
|
||||
@@ -8,7 +8,12 @@ class TestDocumentPageShowDiff(common.TransactionCase):
|
||||
|
||||
def test_show_demo_page1_diff(self):
|
||||
"""Show test page history difference."""
|
||||
page = self.env.ref("document_page.demo_page1")
|
||||
page = self.env["document.page"].create(
|
||||
{
|
||||
"name": "Test Page",
|
||||
"content": "<div>Initial content</div>",
|
||||
}
|
||||
)
|
||||
|
||||
show_diff_object = self.env["wizard.document.page.history.show_diff"]
|
||||
|
||||
@@ -21,8 +26,8 @@ class TestDocumentPageShowDiff(common.TransactionCase):
|
||||
)._get_diff()
|
||||
)
|
||||
|
||||
page.write({"content": "Text content updated"})
|
||||
page.write({"content": "Text updated"})
|
||||
page.write({"content": "<div>Text content updated</div>"})
|
||||
page.write({"content": "<div>Text updated</div>"})
|
||||
|
||||
history_pages = history_document.search([("page_id", "=", page.id)])
|
||||
|
||||
|
||||
@@ -69,6 +69,7 @@
|
||||
<field
|
||||
name="diff"
|
||||
widget="html"
|
||||
class="o_document_page_diff"
|
||||
style="overflow-x: scroll"
|
||||
/>
|
||||
</page>
|
||||
|
||||
@@ -27,4 +27,4 @@ class DocumentPageShowDiff(models.TransientModel):
|
||||
raise UserError(self.env._("Select one or maximum two history revisions!"))
|
||||
return diff
|
||||
|
||||
diff = fields.Html(readonly=True, default=_get_diff)
|
||||
diff = fields.Html(readonly=True, default=_get_diff, sanitize_tags=False)
|
||||
|
||||
@@ -42,7 +42,7 @@ class TestDocumentPageApproval(BaseCommon):
|
||||
{
|
||||
"name": "This page requires approval",
|
||||
"parent_id": cls.category2.id,
|
||||
"content": "This content will require approval",
|
||||
"content": "<p>This content will require approval</p>",
|
||||
}
|
||||
)
|
||||
|
||||
@@ -73,7 +73,7 @@ class TestDocumentPageApproval(BaseCommon):
|
||||
self.assertEqual(chreq.content, page.content)
|
||||
|
||||
# Create new change request
|
||||
page.write({"content": "New content"})
|
||||
page.write({"content": "<p>New content</p>"})
|
||||
page.invalidate_model() # Recompute fields
|
||||
chreq = self.history_obj.search(
|
||||
[("page_id", "=", page.id), ("state", "!=", "approved")], limit=1
|
||||
@@ -81,14 +81,14 @@ class TestDocumentPageApproval(BaseCommon):
|
||||
|
||||
# Approve new changes
|
||||
chreq.with_user(self.user2).action_approve()
|
||||
self.assertEqual(page.content, "New content")
|
||||
self.assertEqual(page.content, "<p>New content</p>")
|
||||
|
||||
def test_change_request_auto_approve(self):
|
||||
"""Test that a page without approval required auto-approves changes."""
|
||||
page = self.page1
|
||||
self.assertFalse(page.is_approval_required)
|
||||
page.write({"content": "New content"})
|
||||
self.assertEqual(page.content, "New content")
|
||||
page.write({"content": "<p>New content</p>"})
|
||||
self.assertEqual(page.content, "<p>New content</p>")
|
||||
|
||||
def test_change_request_from_scratch(self):
|
||||
"""Test a full change request lifecycle from draft to approval."""
|
||||
@@ -104,7 +104,7 @@ class TestDocumentPageApproval(BaseCommon):
|
||||
{
|
||||
"page_id": page.id,
|
||||
"summary": "Changed something",
|
||||
"content": "New content",
|
||||
"content": "<p>New content</p>",
|
||||
}
|
||||
)
|
||||
|
||||
@@ -245,7 +245,7 @@ class TestDocumentPageApproval(BaseCommon):
|
||||
self.history_obj.create(
|
||||
{
|
||||
"page_id": self.page2.id,
|
||||
"content": "Version 1",
|
||||
"content": "<p>Version 1</p>",
|
||||
"state": "approved",
|
||||
}
|
||||
)
|
||||
@@ -253,7 +253,7 @@ class TestDocumentPageApproval(BaseCommon):
|
||||
chreq2 = self.history_obj.create(
|
||||
{
|
||||
"page_id": self.page2.id,
|
||||
"content": "Version 2",
|
||||
"content": "<p>Version 2</p>",
|
||||
}
|
||||
)
|
||||
chreq2._compute_diff()
|
||||
|
||||
@@ -51,8 +51,8 @@ class TestDocumentReference(BaseCommon):
|
||||
new_page_duplicated_name = self.page_obj.create(
|
||||
{
|
||||
"name": "test page with no reference",
|
||||
"content": "this should have an empty reference "
|
||||
"because reference must be unique",
|
||||
"content": "<p>this should have an empty reference "
|
||||
"because reference must be unique</p>",
|
||||
}
|
||||
)
|
||||
self.assertFalse(new_page_duplicated_name.reference)
|
||||
|
||||
Reference in New Issue
Block a user