Skip to content

Commit e660a86

Browse files
naousseFernandoRomera
authored andcommitted
[MIG] document_page: Migration to 9.0
1 parent 705b519 commit e660a86

26 files changed

+329
-154
lines changed

document_page/README.rst

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
2+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
3+
:alt: License: AGPL-3
4+
5+
=============
6+
Document Page
7+
=============
8+
9+
This module allows you to write web pages for internal documentation.
10+
11+
Installation
12+
============
13+
14+
This module depends on module knowledge. So make sure to have it in your addons list.
15+
16+
Configuration
17+
=============
18+
19+
No configuration required
20+
21+
Usage
22+
=====
23+
24+
To use this module, you need to:
25+
26+
* Go to Knowledge menu
27+
* Click on Categories to create the document's category you need with the template
28+
* Click on Pages to create pages and select the previous category to use the template
29+
30+
31+
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
32+
:alt: Try me on Runbot
33+
:target: https://runbot.odoo-community.org/runbot/118/9.0
34+
35+
Known issues / Roadmap
36+
======================
37+
38+
Bug Tracker
39+
===========
40+
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 smashing it by providing a detailed and welcomed feedback `here <https://github.com/OCA/knowledge/issues/new?body=module:%20document_page%0Aversion:%209.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
44+
45+
Credits
46+
=======
47+
48+
Contributors
49+
------------
50+
51+
* Odoo SA <[email protected]>
52+
* Savoir-faire Linux <[email protected]>
53+
* Gervais Naoussi <[email protected]>
54+
55+
Maintainer
56+
----------
57+
58+
.. image:: https://odoo-community.org/logo.png
59+
:alt: Odoo Community Association
60+
:target: https://odoo-community.org
61+
62+
This module is maintained by the OCA.
63+
64+
OCA, or the Odoo Community Association, is a nonprofit organization whose
65+
mission is to support the collaborative development of Odoo features and
66+
promote its widespread use.
67+
68+
To contribute to this module, please visit http://odoo-community.org.

document_page/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@
1818
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1919
#
2020
##############################################################################
21-
from . import document_page
21+
from . import models
2222
from . import wizard

document_page/__openerp__.py

+10-16
Original file line numberDiff line numberDiff line change
@@ -21,35 +21,29 @@
2121

2222
{
2323
'name': 'Document Page',
24-
'version': '8.0.1.0.1',
24+
'version': '9.0.1.0.1',
2525
'category': 'Knowledge Management',
26-
'description': """
27-
Pages
28-
=====
29-
Web pages
30-
""",
31-
'author': ['OpenERP SA'],
26+
'author': 'OpenERP SA, Odoo Community Association (OCA)',
27+
'images': ['images/category_list.png', 'images/create_category.png',
28+
'images/page_list.png', 'images/create_page.png',
29+
'images/customer_invoice.jpeg', 'images/page_history.png'],
3230
'website': 'http://www.openerp.com/',
3331
'license': 'AGPL-3',
3432
'depends': [
35-
'knowledge',
3633
'mail',
34+
'knowledge',
3735
],
3836
'data': [
39-
'wizard/document_page_create_menu_view.xml',
40-
'wizard/document_page_show_diff_view.xml',
41-
'document_page_view.xml',
37+
'wizard/document_page_create_menu.xml',
38+
'wizard/document_page_show_diff.xml',
39+
'views/document_page.xml',
4240
'security/document_page_security.xml',
4341
'security/ir.model.access.csv',
4442
],
4543
'demo': [
46-
'document_page_demo.xml'
47-
],
48-
'test': [
49-
'test/document_page_test00.yml'
44+
'demo/document_page.xml'
5045
],
5146
'installable': True,
5247
'auto_install': False,
53-
'images': [],
5448
'css': ['static/src/css/document_page.css'],
5549
}

document_page/document_page_data.xml document_page/data/document_page.xml

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<openerp>
2+
<odoo>
33
<data noupdate="1">
44
<record id="wiki_wiki_main" model="document.page">
5-
<field name="name">The OpenERP wiki</field>
5+
<field name="name">The Odoo wiki</field>
66
<field name="tags">help, quick start, wiki, formatting</field>
77
<field name="minor_edit">0</field>
88
<field name="index">1</field>
99
<field name="summary">Initial Page</field>
10-
<field name="content">==The OpenERP wiki==
11-
12-
[[File:http://www.openerp.com/sites/all/themes/openerp/logo.png OpenERP]]
10+
<field name="content">== The Odoo wiki ==
1311

14-
The OpenERP wiki allows you to manage your enterprise's contents using wiki
12+
[[File:https://www.odoo.com/openerp_website/static/src/img/logo_transparent_198px.png Odoo]]
13+
14+
The Odoo wiki allows you to manage your enterprise's contents using wiki
1515
restructured texts. This module provides a collaborative way to manage internal
1616
FAQs, quality manuals, technical references, etc.
1717

@@ -38,4 +38,4 @@ FAQs, quality manuals, technical references, etc.
3838
<field name="parent_id" ref="wiki_groups_wikiformatting0"/>
3939
</record>
4040
</data>
41-
</openerp>
41+
</odoo>

document_page/document_page_demo.xml document_page/demo/document_page.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<openerp>
2+
<odoo>
33
<data noupdate="1">
44
<record id="base.user_demo" model="res.users">
55
<field eval="[(4, ref('base.group_document_user'))]"
@@ -128,4 +128,4 @@ Think of it as an out-of-the-box solution to boost your business' productivity.<
128128
</record>
129129

130130
</data>
131-
</openerp>
131+
</odoo>
68.4 KB
Loading
75 KB
Loading

document_page/images/create_page.png

73.2 KB
Loading

document_page/images/page_history.png

95.4 KB
Loading

document_page/images/page_list.png

79.1 KB
Loading

document_page/models/__init__.py

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# -*- coding: utf-8 -*-
2+
##############################################################################
3+
#
4+
# OpenERP, Open Source Management Solution
5+
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
6+
#
7+
# This program is free software: you can redistribute it and/or modify
8+
# it under the terms of the GNU Affero General Public License as
9+
# published by the Free Software Foundation, either version 3 of the
10+
# License, or (at your option) any later version.
11+
#
12+
# This program is distributed in the hope that it will be useful,
13+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
# GNU Affero General Public License for more details.
16+
#
17+
# You should have received a copy of the GNU Affero General Public License
18+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
19+
#
20+
##############################################################################
21+
from . import document_page
22+
from . import document_page_history

document_page/document_page.py document_page/models/document_page.py

+12-48
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,14 @@
1919
#
2020
##############################################################################
2121
import logging
22-
import difflib
23-
from openerp import models, fields, api, _
22+
from openerp import models, fields, api
2423

2524
_logger = logging.getLogger(__name__)
2625

2726

28-
class document_page(models.Model):
27+
class DocumentPage(models.Model):
28+
"""This class is use to manage Document."""
29+
2930
_name = "document.page"
3031
_inherit = ['mail.thread']
3132
_description = "Document Page"
@@ -99,6 +100,7 @@ class document_page(models.Model):
99100
)
100101

101102
def _get_page_index(self, page, link=True):
103+
"""Return the index of a document."""
102104
index = []
103105
for subpage in page.child_ids:
104106
index += ["<li>" + self._get_page_index(subpage) +
@@ -112,6 +114,7 @@ def _get_page_index(self, page, link=True):
112114
return r
113115

114116
def _get_display_content(self):
117+
"""Return the content of a document."""
115118
for page in self:
116119
if page.type == "category":
117120
display_content = self._get_page_index(page, link=False)
@@ -121,11 +124,13 @@ def _get_display_content(self):
121124

122125
@api.onchange("parent_id")
123126
def do_set_content(self):
127+
"""We Set it the right content to the new parent."""
124128
if self.parent_id and not self.content:
125129
if self.parent_id.type == "category":
126130
self.content = self.parent_id.content
127131

128132
def create_history(self, page_id, content):
133+
"""Create the first history of a newly created document."""
129134
history = self.env['document.page.history']
130135
return history.create({
131136
"content": content,
@@ -134,7 +139,8 @@ def create_history(self, page_id, content):
134139

135140
@api.multi
136141
def write(self, vals):
137-
result = super(document_page, self).write(vals)
142+
"""Write the content and set the history."""
143+
result = super(DocumentPage, self).write(vals)
138144
content = vals.get('content')
139145
if content:
140146
for page in self:
@@ -144,51 +150,9 @@ def write(self, vals):
144150
@api.model
145151
@api.returns('self', lambda value: value.id)
146152
def create(self, vals):
147-
page_id = super(document_page, self).create(vals)
153+
"""Create the first history of a document."""
154+
page_id = super(DocumentPage, self).create(vals)
148155
content = vals.get('content')
149156
if content:
150157
self.create_history(page_id.id, content)
151158
return page_id
152-
153-
154-
class document_page_history(models.Model):
155-
_name = "document.page.history"
156-
_description = "Document Page History"
157-
_order = 'id DESC'
158-
_rec_name = "create_date"
159-
160-
page_id = fields.Many2one('document.page', 'Page')
161-
summary = fields.Char('Summary', size=256, select=True)
162-
content = fields.Text("Content")
163-
create_date = fields.Datetime("Date")
164-
create_uid = fields.Many2one('res.users', "Modified By")
165-
166-
def getDiff(self, v1, v2):
167-
text1 = self.browse(v1).content
168-
text2 = self.browse(v2).content
169-
line1 = line2 = ''
170-
if text1:
171-
line1 = text1.splitlines(1)
172-
if text2:
173-
line2 = text2.splitlines(1)
174-
if (not line1 and not line2) or (line1 == line2):
175-
return _('There are no changes in revisions.')
176-
else:
177-
diff = difflib.HtmlDiff()
178-
return diff.make_table(
179-
line1, line2,
180-
"Revision-{}".format(v1),
181-
"Revision-{}".format(v2),
182-
context=True
183-
)
184-
185-
def __getattr__(self, attr):
186-
"""Return a dummy callabale"""
187-
if attr in ['_sql', 'init', '_ids']:
188-
raise AttributeError
189-
190-
_logger.warning(
191-
"Trying to access attribute %s on document_page_history",
192-
attr
193-
)
194-
return (lambda *a, **b: None)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# -*- coding: utf-8 -*-
2+
##############################################################################
3+
#
4+
# OpenERP, Open Source Management Solution
5+
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
6+
#
7+
# This program is free software: you can redistribute it and/or modify
8+
# it under the terms of the GNU Affero General Public License as
9+
# published by the Free Software Foundation, either version 3 of the
10+
# License, or (at your option) any later version.
11+
#
12+
# This program is distributed in the hope that it will be useful,
13+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
# GNU Affero General Public License for more details.
16+
#
17+
# You should have received a copy of the GNU Affero General Public License
18+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
19+
#
20+
##############################################################################
21+
import logging
22+
import difflib
23+
from openerp import models, fields, _
24+
25+
_logger = logging.getLogger(__name__)
26+
27+
28+
class DocumentPageHistory(models.Model):
29+
"""This model is necessary to manage a document history."""
30+
31+
_name = "document.page.history"
32+
_description = "Document Page History"
33+
_order = 'id DESC'
34+
_rec_name = "create_date"
35+
36+
page_id = fields.Many2one('document.page', 'Page')
37+
summary = fields.Char('Summary', select=True)
38+
content = fields.Text("Content")
39+
create_date = fields.Datetime("Date")
40+
create_uid = fields.Many2one('res.users', "Modified By")
41+
42+
def getDiff(self, v1, v2):
43+
"""Return the difference between two version of document version."""
44+
text1 = self.browse(v1).content
45+
text2 = self.browse(v2).content
46+
line1 = line2 = ''
47+
if text1:
48+
line1 = text1.splitlines(1)
49+
if text2:
50+
line2 = text2.splitlines(1)
51+
if (not line1 and not line2) or (line1 == line2):
52+
return _('There are no changes in revisions.')
53+
else:
54+
diff = difflib.HtmlDiff()
55+
return diff.make_table(
56+
line1, line2,
57+
"Revision-{}".format(v1),
58+
"Revision-{}".format(v2),
59+
context=True
60+
)
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<openerp>
2+
<odoo>
33
<data noupdate="0">
44
<record id="base.group_document_user" model="res.groups">
55
<field name="users" eval="[(4, ref('base.user_root'))]"/>
66
</record>
77
</data>
8-
</openerp>
8+
</odoo>

0 commit comments

Comments
 (0)