Skip to content

Commit 28bd2f8

Browse files
MiquelRForgeFlowFernandoRomera
authored andcommitted
[MIG] document_page: Migration to 12.0
1 parent b7212b3 commit 28bd2f8

25 files changed

+51
-60
lines changed

document_page/README.rst

+8-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
2-
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
1+
.. image:: https://img.shields.io/badge/license-AGPL--3-blue.png
2+
:target: https://www.gnu.org/licenses/agpl
33
:alt: License: AGPL-3
44

55
=============
@@ -30,25 +30,23 @@ To use this module, you need to:
3030

3131
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
3232
:alt: Try me on Runbot
33-
:target: https://runbot.odoo-community.org/runbot/118/11.0
34-
35-
Known issues / Roadmap
36-
======================
33+
:target: https://runbot.odoo-community.org/runbot/118/12.0
3734

3835
Bug Tracker
3936
===========
4037

41-
Bugs are tracked on `GitHub Issues <https://github.com/OCA/Knowledge/issues>`_.
42-
In case of trouble, please check there if your issue has already been reported.
43-
If you spotted it first, help us smash it by providing detailed and welcomed feedback.
38+
Bugs are tracked on `GitHub Issues
39+
<https://github.com/OCA/knowledge/issues>`_. In case of trouble, please
40+
check there if your issue has already been reported. If you spotted it first,
41+
help us smash it by providing detailed and welcomed feedback.
4442

4543
Credits
4644
=======
4745

4846
Images
4947
------
5048

51-
* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.
49+
* Odoo Community Association: `Icon <https://odoo-community.org/logo.png>`_.
5250

5351
Contributors
5452
------------

document_page/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
21
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
32

43
from . import models

document_page/__manifest__.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
{
66
'name': 'Document Page',
7-
'version': '11.0.2.3.0',
7+
'version': '12.0.1.0.0',
88
'category': 'Knowledge Management',
99
'author': 'OpenERP SA, Odoo Community Association (OCA)',
1010
'images': [
@@ -22,15 +22,15 @@
2222
'knowledge',
2323
],
2424
'data': [
25+
'security/document_page_security.xml',
26+
'security/ir.model.access.csv',
2527
'wizard/document_page_create_menu.xml',
2628
'wizard/document_page_show_diff.xml',
2729
'views/document_page.xml',
2830
'views/document_page_category.xml',
2931
'views/document_page_history.xml',
3032
'views/document_page_assets.xml',
3133
'views/report_document_page.xml',
32-
'security/document_page_security.xml',
33-
'security/ir.model.access.csv',
3434
],
3535
'demo': [
3636
'demo/document_page.xml'

document_page/migrations/10.0.2.0.0/post-migration.py

-12
This file was deleted.

document_page/models/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
21
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
32

43
from . import document_page

document_page/models/document_page.py

-11
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,23 @@ class DocumentPage(models.Model):
1414
_order = 'name'
1515

1616
name = fields.Char('Title', required=True)
17-
1817
type = fields.Selection(
1918
[('content', 'Content'), ('category', 'Category')],
2019
'Type',
2120
help="Page type",
2221
default="content"
2322
)
24-
2523
active = fields.Boolean(default=True)
26-
2724
parent_id = fields.Many2one(
2825
'document.page',
2926
'Category',
3027
domain=[('type', '=', 'category')]
3128
)
32-
3329
child_ids = fields.One2many(
3430
'document.page',
3531
'parent_id',
3632
'Children'
3733
)
38-
3934
content = fields.Text(
4035
"Content",
4136
compute='_compute_content',
@@ -65,37 +60,32 @@ class DocumentPage(models.Model):
6560
help="Template that will be used as a content template "
6661
"for all new page of this category.",
6762
)
68-
6963
history_head = fields.Many2one(
7064
'document.page.history',
7165
'HEAD',
7266
compute='_compute_history_head',
7367
store=True,
7468
auto_join=True,
7569
)
76-
7770
history_ids = fields.One2many(
7871
'document.page.history',
7972
'page_id',
8073
'History',
8174
order='create_date DESC',
8275
readonly=True,
8376
)
84-
8577
menu_id = fields.Many2one(
8678
'ir.ui.menu',
8779
"Menu",
8880
readonly=True,
8981
)
90-
9182
content_date = fields.Datetime(
9283
'Last Contribution Date',
9384
related='history_head.create_date',
9485
store=True,
9586
index=True,
9687
readonly=True,
9788
)
98-
9989
content_uid = fields.Many2one(
10090
'res.users',
10191
'Last Contributor',
@@ -104,7 +94,6 @@ class DocumentPage(models.Model):
10494
index=True,
10595
readonly=True,
10696
)
107-
10897
company_id = fields.Many2one(
10998
'res.company',
11099
'Company',

document_page/models/document_page_history.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -40,21 +40,21 @@ def _compute_diff(self):
4040
limit=1,
4141
order='create_date DESC')
4242
if prev:
43-
rec.diff = self.getDiff(prev.id, rec.id)
43+
rec.diff = self._get_diff(prev.id, rec.id)
4444
else:
45-
rec.diff = self.getDiff(False, rec.id)
45+
rec.diff = self._get_diff(False, rec.id)
4646

4747
@api.model
48-
def getDiff(self, v1, v2):
48+
def _get_diff(self, v1, v2):
4949
"""Return the difference between two version of document version."""
5050
text1 = v1 and self.browse(v1).content or ''
5151
text2 = v2 and self.browse(v2).content or ''
5252
# Include line breaks to make it more readable
5353
# TODO: consider using a beautify library directly on the content
5454
text1 = text1.replace('</p><p>', '</p>\r\n<p>')
5555
text2 = text2.replace('</p><p>', '</p>\r\n<p>')
56-
line1 = text1.splitlines(1)
57-
line2 = text2.splitlines(1)
56+
line1 = text1.splitlines(True)
57+
line2 = text2.splitlines(True)
5858
if line1 == line2:
5959
return _('There are no changes in revisions.')
6060
else:

document_page/readme/CONFIGURE.rst

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
No configuration required.

document_page/readme/CONTRIBUTORS.rst

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
* Gervais Naoussi <[email protected]>
2+
* Maxime Chambreuil <[email protected]>
3+
* Iván Todorovich <[email protected]>
4+
* Jose Maria Alzaga <[email protected]>
5+
* Lois Rilo <[email protected]>

document_page/readme/CREDITS.rst

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
The development of this module has been financially supported by:
2+
3+
* Odoo SA <http://www.odoo.com>
4+
* Savoir-faire Linux <http://www.savoirfairelinux.com>

document_page/readme/DESCRIPTION.rst

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This module allows you to write web pages for internal documentation.

document_page/readme/INSTALL.rst

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This module depends on module knowledge. So make sure to have it in your addons list.

document_page/readme/USAGE.rst

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
To use this module, you need to:
2+
3+
* Go to Knowledge menu
4+
* Click on Categories to create the document's category you need with the template
5+
* Click on Pages to create pages and select the previous category to use the template

document_page/security/document_page_security.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<field name="name">Manager</field>
1212
<field name="category_id" ref="knowledge.module_category_knowledge"/>
1313
<field name="implied_ids" eval="[(4, ref('group_document_editor'))]"/>
14-
<field name="users" eval="[(4, ref('base.user_root'))]"/>
14+
<field name="users" eval="[(4, ref('base.user_admin'))]"/>
1515
</record>
1616

1717
<record model="ir.rule" id="document_page_rule">

document_page/tests/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
12

23
from . import test_document_page
34
from . import test_document_page_create_menu

document_page/tests/test_document_page.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
1+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
22
from odoo.tests import common
33

44

document_page/tests/test_document_page_create_menu.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
1+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
22
from odoo.tests import common
33

44

document_page/tests/test_document_page_history.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ def test_page_history_demo_page1(self):
1313
history_pages = history_document.search([('page_id', '=', page.id)])
1414
active_ids = [i.id for i in history_pages]
1515

16-
result = history_document.getDiff(active_ids[0], active_ids[0])
16+
result = history_document._get_diff(active_ids[0], active_ids[0])
1717
self.assertEqual(result, 'There are no changes in revisions.')
1818

19-
result = history_document.getDiff(active_ids[0], active_ids[1])
19+
result = history_document._get_diff(active_ids[0], active_ids[1])
2020
self.assertNotEqual(result, 'There are no changes in revisions.')

document_page/tests/test_document_page_show_diff.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
12
from odoo.exceptions import UserError
23
from odoo.tests import common
34

document_page/views/document_page.xml

+3-3
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,9 @@
117117
<field name="create_uid"/>
118118
<field name="content_uid"/>
119119
<group expand="0" string="Group By...">
120-
<filter string="Category" context="{'group_by':'parent_id'}"/>
121-
<filter string="Author" context="{'group_by':'create_uid'}"/>
122-
<filter string="Last Contributor" context="{'group_by':'content_uid'}"/>
120+
<filter name="group_by_category" string="Category" context="{'group_by':'parent_id'}"/>
121+
<filter name="group_by_author" string="Author" context="{'group_by':'create_uid'}"/>
122+
<filter name="group_by_last_contributor" string="Last Contributor" context="{'group_by':'content_uid'}"/>
123123
</group>
124124
</search>
125125
</field>

document_page/views/document_page_category.xml

+3-3
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@
6262
<field name="create_uid"/>
6363
<field name="content_uid"/>
6464
<group expand="0" string="Group By...">
65-
<filter string="Category" context="{'group_by':'parent_id'}"/>
66-
<filter string="Author" context="{'group_by':'create_uid'}"/>
67-
<filter string="Last Contributor" context="{'group_by':'content_uid'}"/>
65+
<filter name="group_by_category" string="Category" context="{'group_by':'parent_id'}"/>
66+
<filter name="group_by_author" string="Author" context="{'group_by':'create_uid'}"/>
67+
<filter name="group_by_last_contributor" string="Last Contributor" context="{'group_by':'content_uid'}"/>
6868
</group>
6969
</search>
7070
</field>

document_page/views/document_page_history.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
<field name="content"/>
2828
<field name="create_uid"/>
2929
<group expand="0" string="Group By...">
30-
<filter name="group_author" string="Author" context="{'group_by':'create_uid'}" />
30+
<filter name="group_by_author" string="Author" context="{'group_by':'create_uid'}" />
3131
</group>
3232
</search>
3333
</field>

document_page/wizard/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
21
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
32

43
from . import document_page_create_menu

document_page/wizard/document_page_create_menu.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ class DocumentPageCreateMenu(models.TransientModel):
1414
'Menu Name',
1515
required=True
1616
)
17-
1817
menu_parent_id = fields.Many2one(
1918
'ir.ui.menu',
2019
'Parent Menu',
@@ -53,7 +52,7 @@ def document_page_menu_create(self):
5352
'type': 'ir.actions.act_window',
5453
'target': 'current',
5554
}
56-
value['domain'] = "[('parent_id','=',%d)]" % (page.id)
55+
value['domain'] = "[('parent_id','=',%d)]" % page.id
5756
value['res_id'] = page.id
5857

5958
# only the super user is allowed to create menu due to security rules

document_page/wizard/document_page_show_diff.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ class DocumentPageShowDiff(models.TransientModel):
1010
"""Display Difference for History."""
1111

1212
_name = 'wizard.document.page.history.show_diff'
13+
_description = 'Document Page Show Diff'
1314

1415
def _get_diff(self):
1516
"""Return the Difference between two document."""
@@ -18,9 +19,9 @@ def _get_diff(self):
1819
diff = False
1920
if len(ids) == 2:
2021
if ids[0] > ids[1]:
21-
diff = history.getDiff(ids[1], ids[0])
22+
diff = history._get_diff(ids[1], ids[0])
2223
else:
23-
diff = history.getDiff(ids[0], ids[1])
24+
diff = history._get_diff(ids[0], ids[1])
2425
elif len(ids) == 1:
2526
diff = history.browse(ids[0]).diff
2627
else:

0 commit comments

Comments
 (0)