mirror of
https://github.com/OCA/knowledge.git
synced 2025-07-13 15:34:49 -06:00
[MIG] document_page: Migration to 12.0
This commit is contained in:
parent
fc22ca50fb
commit
792991fba3
@ -1,5 +1,5 @@
|
||||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
|
||||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
|
||||
.. image:: https://img.shields.io/badge/license-AGPL--3-blue.png
|
||||
:target: https://www.gnu.org/licenses/agpl
|
||||
:alt: License: AGPL-3
|
||||
|
||||
=============
|
||||
@ -30,17 +30,15 @@ To use this module, you need to:
|
||||
|
||||
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
|
||||
:alt: Try me on Runbot
|
||||
:target: https://runbot.odoo-community.org/runbot/118/11.0
|
||||
|
||||
Known issues / Roadmap
|
||||
======================
|
||||
:target: https://runbot.odoo-community.org/runbot/118/12.0
|
||||
|
||||
Bug Tracker
|
||||
===========
|
||||
|
||||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/Knowledge/issues>`_.
|
||||
In case of trouble, please check there if your issue has already been reported.
|
||||
If you spotted it first, help us smash it by providing detailed and welcomed feedback.
|
||||
Bugs are tracked on `GitHub Issues
|
||||
<https://github.com/OCA/knowledge/issues>`_. In case of trouble, please
|
||||
check there if your issue has already been reported. If you spotted it first,
|
||||
help us smash it by providing detailed and welcomed feedback.
|
||||
|
||||
Credits
|
||||
=======
|
||||
@ -48,7 +46,7 @@ Credits
|
||||
Images
|
||||
------
|
||||
|
||||
* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.
|
||||
* Odoo Community Association: `Icon <https://odoo-community.org/logo.png>`_.
|
||||
|
||||
Contributors
|
||||
------------
|
||||
|
@ -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 models
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
{
|
||||
'name': 'Document Page',
|
||||
'version': '11.0.2.3.0',
|
||||
'version': '12.0.1.0.0',
|
||||
'category': 'Knowledge Management',
|
||||
'author': 'OpenERP SA, Odoo Community Association (OCA)',
|
||||
'images': [
|
||||
@ -22,6 +22,8 @@
|
||||
'knowledge',
|
||||
],
|
||||
'data': [
|
||||
'security/document_page_security.xml',
|
||||
'security/ir.model.access.csv',
|
||||
'wizard/document_page_create_menu.xml',
|
||||
'wizard/document_page_show_diff.xml',
|
||||
'views/document_page.xml',
|
||||
@ -29,8 +31,6 @@
|
||||
'views/document_page_history.xml',
|
||||
'views/document_page_assets.xml',
|
||||
'views/report_document_page.xml',
|
||||
'security/document_page_security.xml',
|
||||
'security/ir.model.access.csv',
|
||||
],
|
||||
'demo': [
|
||||
'demo/document_page.xml'
|
||||
|
@ -1,12 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2018 Ivan Todorovich <ivan.todorovich@gmail.com>
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
|
||||
def migrate(cr, version): # pragma: no cover
|
||||
# Set all pre-existing categories template to its content
|
||||
cr.execute("""
|
||||
UPDATE document_page
|
||||
SET template = content
|
||||
WHERE type = 'category'
|
||||
""")
|
@ -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
|
||||
|
@ -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',
|
||||
|
@ -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:
|
||||
|
1
document_page/readme/CONFIGURE.rst
Normal file
1
document_page/readme/CONFIGURE.rst
Normal file
@ -0,0 +1 @@
|
||||
No configuration required.
|
5
document_page/readme/CONTRIBUTORS.rst
Normal file
5
document_page/readme/CONTRIBUTORS.rst
Normal file
@ -0,0 +1,5 @@
|
||||
* 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@eficent.com>
|
4
document_page/readme/CREDITS.rst
Normal file
4
document_page/readme/CREDITS.rst
Normal file
@ -0,0 +1,4 @@
|
||||
The development of this module has been financially supported by:
|
||||
|
||||
* Odoo SA <http://www.odoo.com>
|
||||
* Savoir-faire Linux <http://www.savoirfairelinux.com>
|
1
document_page/readme/DESCRIPTION.rst
Normal file
1
document_page/readme/DESCRIPTION.rst
Normal file
@ -0,0 +1 @@
|
||||
This module allows you to write web pages for internal documentation.
|
1
document_page/readme/INSTALL.rst
Normal file
1
document_page/readme/INSTALL.rst
Normal file
@ -0,0 +1 @@
|
||||
This module depends on module knowledge. So make sure to have it in your addons list.
|
5
document_page/readme/USAGE.rst
Normal file
5
document_page/readme/USAGE.rst
Normal file
@ -0,0 +1,5 @@
|
||||
To use this module, you need to:
|
||||
|
||||
* Go to Knowledge menu
|
||||
* Click on Categories to create the document's category you need with the template
|
||||
* Click on Pages to create pages and select the previous category to use the template
|
@ -11,7 +11,7 @@
|
||||
<field name="name">Manager</field>
|
||||
<field name="category_id" ref="knowledge.module_category_knowledge"/>
|
||||
<field name="implied_ids" eval="[(4, ref('group_document_editor'))]"/>
|
||||
<field name="users" eval="[(4, ref('base.user_root'))]"/>
|
||||
<field name="users" eval="[(4, ref('base.user_admin'))]"/>
|
||||
</record>
|
||||
|
||||
<record model="ir.rule" id="document_page_rule">
|
||||
|
@ -1,3 +1,4 @@
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from . import test_document_page
|
||||
from . import test_document_page_create_menu
|
||||
|
@ -1,4 +1,4 @@
|
||||
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
from odoo.tests import common
|
||||
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
from odoo.tests import common
|
||||
|
||||
|
||||
|
@ -13,8 +13,8 @@ class TestDocumentPageHistory(common.TransactionCase):
|
||||
history_pages = history_document.search([('page_id', '=', page.id)])
|
||||
active_ids = [i.id for i in history_pages]
|
||||
|
||||
result = history_document.getDiff(active_ids[0], active_ids[0])
|
||||
result = history_document._get_diff(active_ids[0], active_ids[0])
|
||||
self.assertEqual(result, 'There are no changes in revisions.')
|
||||
|
||||
result = history_document.getDiff(active_ids[0], active_ids[1])
|
||||
result = history_document._get_diff(active_ids[0], active_ids[1])
|
||||
self.assertNotEqual(result, 'There are no changes in revisions.')
|
||||
|
@ -1,3 +1,4 @@
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
from odoo.exceptions import UserError
|
||||
from odoo.tests import common
|
||||
|
||||
|
@ -117,9 +117,9 @@
|
||||
<field name="create_uid"/>
|
||||
<field name="content_uid"/>
|
||||
<group expand="0" string="Group By...">
|
||||
<filter string="Category" context="{'group_by':'parent_id'}"/>
|
||||
<filter string="Author" context="{'group_by':'create_uid'}"/>
|
||||
<filter string="Last Contributor" context="{'group_by':'content_uid'}"/>
|
||||
<filter name="group_by_category" string="Category" context="{'group_by':'parent_id'}"/>
|
||||
<filter name="group_by_author" string="Author" context="{'group_by':'create_uid'}"/>
|
||||
<filter name="group_by_last_contributor" string="Last Contributor" context="{'group_by':'content_uid'}"/>
|
||||
</group>
|
||||
</search>
|
||||
</field>
|
||||
|
@ -62,9 +62,9 @@
|
||||
<field name="create_uid"/>
|
||||
<field name="content_uid"/>
|
||||
<group expand="0" string="Group By...">
|
||||
<filter string="Category" context="{'group_by':'parent_id'}"/>
|
||||
<filter string="Author" context="{'group_by':'create_uid'}"/>
|
||||
<filter string="Last Contributor" context="{'group_by':'content_uid'}"/>
|
||||
<filter name="group_by_category" string="Category" context="{'group_by':'parent_id'}"/>
|
||||
<filter name="group_by_author" string="Author" context="{'group_by':'create_uid'}"/>
|
||||
<filter name="group_by_last_contributor" string="Last Contributor" context="{'group_by':'content_uid'}"/>
|
||||
</group>
|
||||
</search>
|
||||
</field>
|
||||
|
@ -27,7 +27,7 @@
|
||||
<field name="content"/>
|
||||
<field name="create_uid"/>
|
||||
<group expand="0" string="Group By...">
|
||||
<filter name="group_author" string="Author" context="{'group_by':'create_uid'}" />
|
||||
<filter name="group_by_author" string="Author" context="{'group_by':'create_uid'}" />
|
||||
</group>
|
||||
</search>
|
||||
</field>
|
||||
|
@ -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_create_menu
|
||||
|
@ -14,7 +14,6 @@ class DocumentPageCreateMenu(models.TransientModel):
|
||||
'Menu Name',
|
||||
required=True
|
||||
)
|
||||
|
||||
menu_parent_id = fields.Many2one(
|
||||
'ir.ui.menu',
|
||||
'Parent Menu',
|
||||
@ -53,7 +52,7 @@ class DocumentPageCreateMenu(models.TransientModel):
|
||||
'type': 'ir.actions.act_window',
|
||||
'target': 'current',
|
||||
}
|
||||
value['domain'] = "[('parent_id','=',%d)]" % (page.id)
|
||||
value['domain'] = "[('parent_id','=',%d)]" % page.id
|
||||
value['res_id'] = page.id
|
||||
|
||||
# only the super user is allowed to create menu due to security rules
|
||||
|
@ -10,6 +10,7 @@ class DocumentPageShowDiff(models.TransientModel):
|
||||
"""Display Difference for History."""
|
||||
|
||||
_name = 'wizard.document.page.history.show_diff'
|
||||
_description = 'Document Page Show Diff'
|
||||
|
||||
def _get_diff(self):
|
||||
"""Return the Difference between two document."""
|
||||
@ -18,9 +19,9 @@ class DocumentPageShowDiff(models.TransientModel):
|
||||
diff = False
|
||||
if len(ids) == 2:
|
||||
if ids[0] > ids[1]:
|
||||
diff = history.getDiff(ids[1], ids[0])
|
||||
diff = history._get_diff(ids[1], ids[0])
|
||||
else:
|
||||
diff = history.getDiff(ids[0], ids[1])
|
||||
diff = history._get_diff(ids[0], ids[1])
|
||||
elif len(ids) == 1:
|
||||
diff = history.browse(ids[0]).diff
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user