From 792991fba3adb69ff3932c802cd922e51165c2cb Mon Sep 17 00:00:00 2001 From: mreficent Date: Tue, 12 Mar 2019 13:23:37 +0100 Subject: [PATCH] [MIG] document_page: Migration to 12.0 --- document_page/README.rst | 18 ++++++++---------- document_page/__init__.py | 1 - document_page/__manifest__.py | 6 +++--- .../migrations/10.0.2.0.0/post-migration.py | 12 ------------ document_page/models/__init__.py | 1 - document_page/models/document_page.py | 11 ----------- document_page/models/document_page_history.py | 10 +++++----- document_page/readme/CONFIGURE.rst | 1 + document_page/readme/CONTRIBUTORS.rst | 5 +++++ document_page/readme/CREDITS.rst | 4 ++++ document_page/readme/DESCRIPTION.rst | 1 + document_page/readme/INSTALL.rst | 1 + document_page/readme/USAGE.rst | 5 +++++ .../security/document_page_security.xml | 2 +- document_page/tests/__init__.py | 1 + document_page/tests/test_document_page.py | 2 +- .../tests/test_document_page_create_menu.py | 2 +- .../tests/test_document_page_history.py | 4 ++-- .../tests/test_document_page_show_diff.py | 1 + document_page/views/document_page.xml | 6 +++--- document_page/views/document_page_category.xml | 6 +++--- document_page/views/document_page_history.xml | 2 +- document_page/wizard/__init__.py | 1 - .../wizard/document_page_create_menu.py | 3 +-- .../wizard/document_page_show_diff.py | 5 +++-- 25 files changed, 51 insertions(+), 60 deletions(-) delete mode 100644 document_page/migrations/10.0.2.0.0/post-migration.py create mode 100644 document_page/readme/CONFIGURE.rst create mode 100644 document_page/readme/CONTRIBUTORS.rst create mode 100644 document_page/readme/CREDITS.rst create mode 100644 document_page/readme/DESCRIPTION.rst create mode 100644 document_page/readme/INSTALL.rst create mode 100644 document_page/readme/USAGE.rst diff --git a/document_page/README.rst b/document_page/README.rst index 8f6ae917..8e0d1059 100644 --- a/document_page/README.rst +++ b/document_page/README.rst @@ -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 `_. -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 +`_. 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 `_. +* Odoo Community Association: `Icon `_. Contributors ------------ diff --git a/document_page/__init__.py b/document_page/__init__.py index 22e29c85..4d7a49b5 100644 --- a/document_page/__init__.py +++ b/document_page/__init__.py @@ -1,4 +1,3 @@ -# Copyright (C) 2004-2010 Tiny SPRL (). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from . import models diff --git a/document_page/__manifest__.py b/document_page/__manifest__.py index 1c390595..6052cf01 100644 --- a/document_page/__manifest__.py +++ b/document_page/__manifest__.py @@ -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' diff --git a/document_page/migrations/10.0.2.0.0/post-migration.py b/document_page/migrations/10.0.2.0.0/post-migration.py deleted file mode 100644 index 5c40d42b..00000000 --- a/document_page/migrations/10.0.2.0.0/post-migration.py +++ /dev/null @@ -1,12 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2018 Ivan Todorovich -# 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' - """) diff --git a/document_page/models/__init__.py b/document_page/models/__init__.py index 01c939a7..aeb44abd 100644 --- a/document_page/models/__init__.py +++ b/document_page/models/__init__.py @@ -1,4 +1,3 @@ -# Copyright (C) 2004-2010 Tiny SPRL (). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from . import document_page diff --git a/document_page/models/document_page.py b/document_page/models/document_page.py index b444e514..0eff4ffc 100644 --- a/document_page/models/document_page.py +++ b/document_page/models/document_page.py @@ -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', diff --git a/document_page/models/document_page_history.py b/document_page/models/document_page_history.py index d7e4a356..7467cf05 100644 --- a/document_page/models/document_page_history.py +++ b/document_page/models/document_page_history.py @@ -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('

', '

\r\n

') text2 = text2.replace('

', '

\r\n

') - 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: diff --git a/document_page/readme/CONFIGURE.rst b/document_page/readme/CONFIGURE.rst new file mode 100644 index 00000000..e7dc2359 --- /dev/null +++ b/document_page/readme/CONFIGURE.rst @@ -0,0 +1 @@ +No configuration required. diff --git a/document_page/readme/CONTRIBUTORS.rst b/document_page/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000..835f2d15 --- /dev/null +++ b/document_page/readme/CONTRIBUTORS.rst @@ -0,0 +1,5 @@ +* Gervais Naoussi +* Maxime Chambreuil +* Iván Todorovich +* Jose Maria Alzaga +* Lois Rilo diff --git a/document_page/readme/CREDITS.rst b/document_page/readme/CREDITS.rst new file mode 100644 index 00000000..c0a09005 --- /dev/null +++ b/document_page/readme/CREDITS.rst @@ -0,0 +1,4 @@ +The development of this module has been financially supported by: + +* Odoo SA +* Savoir-faire Linux diff --git a/document_page/readme/DESCRIPTION.rst b/document_page/readme/DESCRIPTION.rst new file mode 100644 index 00000000..3c046a01 --- /dev/null +++ b/document_page/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +This module allows you to write web pages for internal documentation. diff --git a/document_page/readme/INSTALL.rst b/document_page/readme/INSTALL.rst new file mode 100644 index 00000000..b643617c --- /dev/null +++ b/document_page/readme/INSTALL.rst @@ -0,0 +1 @@ +This module depends on module knowledge. So make sure to have it in your addons list. diff --git a/document_page/readme/USAGE.rst b/document_page/readme/USAGE.rst new file mode 100644 index 00000000..8576f8fc --- /dev/null +++ b/document_page/readme/USAGE.rst @@ -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 diff --git a/document_page/security/document_page_security.xml b/document_page/security/document_page_security.xml index 7124e7fd..e05a2811 100644 --- a/document_page/security/document_page_security.xml +++ b/document_page/security/document_page_security.xml @@ -11,7 +11,7 @@ Manager - + diff --git a/document_page/tests/__init__.py b/document_page/tests/__init__.py index 67afbfa7..8f1890ad 100644 --- a/document_page/tests/__init__.py +++ b/document_page/tests/__init__.py @@ -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 diff --git a/document_page/tests/test_document_page.py b/document_page/tests/test_document_page.py index 9daec4a5..c087623e 100644 --- a/document_page/tests/test_document_page.py +++ b/document_page/tests/test_document_page.py @@ -1,4 +1,4 @@ - +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from odoo.tests import common diff --git a/document_page/tests/test_document_page_create_menu.py b/document_page/tests/test_document_page_create_menu.py index 2f544b2a..96c21e24 100644 --- a/document_page/tests/test_document_page_create_menu.py +++ b/document_page/tests/test_document_page_create_menu.py @@ -1,4 +1,4 @@ - +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from odoo.tests import common diff --git a/document_page/tests/test_document_page_history.py b/document_page/tests/test_document_page_history.py index 590475e2..a80f4cc4 100644 --- a/document_page/tests/test_document_page_history.py +++ b/document_page/tests/test_document_page_history.py @@ -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.') diff --git a/document_page/tests/test_document_page_show_diff.py b/document_page/tests/test_document_page_show_diff.py index 5044c443..34bc16f7 100644 --- a/document_page/tests/test_document_page_show_diff.py +++ b/document_page/tests/test_document_page_show_diff.py @@ -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 diff --git a/document_page/views/document_page.xml b/document_page/views/document_page.xml index edc1a1d5..63477914 100644 --- a/document_page/views/document_page.xml +++ b/document_page/views/document_page.xml @@ -117,9 +117,9 @@ - - - + + + diff --git a/document_page/views/document_page_category.xml b/document_page/views/document_page_category.xml index 730f6f6f..83e7f242 100755 --- a/document_page/views/document_page_category.xml +++ b/document_page/views/document_page_category.xml @@ -62,9 +62,9 @@ - - - + + + diff --git a/document_page/views/document_page_history.xml b/document_page/views/document_page_history.xml index 413fd6e4..d1bb819a 100755 --- a/document_page/views/document_page_history.xml +++ b/document_page/views/document_page_history.xml @@ -27,7 +27,7 @@ - + diff --git a/document_page/wizard/__init__.py b/document_page/wizard/__init__.py index f05bccc2..6ecd6cd6 100644 --- a/document_page/wizard/__init__.py +++ b/document_page/wizard/__init__.py @@ -1,4 +1,3 @@ -# Copyright (C) 2004-2010 Tiny SPRL (). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from . import document_page_create_menu diff --git a/document_page/wizard/document_page_create_menu.py b/document_page/wizard/document_page_create_menu.py index 83c3747c..ee226b9f 100644 --- a/document_page/wizard/document_page_create_menu.py +++ b/document_page/wizard/document_page_create_menu.py @@ -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 diff --git a/document_page/wizard/document_page_show_diff.py b/document_page/wizard/document_page_show_diff.py index 440ce6d6..55d37ab1 100644 --- a/document_page/wizard/document_page_show_diff.py +++ b/document_page/wizard/document_page_show_diff.py @@ -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: