From 6e5bec5a45e021820ef26042994d731139203b22 Mon Sep 17 00:00:00 2001 From: "Victor M.M. Torres" Date: Fri, 23 Aug 2019 17:43:51 +0200 Subject: [PATCH] [MIG] document_page_approval: Migration to v12 --- document_page_approval/README.rst | 97 ++-- document_page_approval/__manifest__.py | 2 +- .../models/document_page_history.py | 22 +- document_page_approval/readme/CONFIGURE.rst | 6 + .../readme/CONTRIBUTORS.rst | 6 + document_page_approval/readme/DESCRIPTION.rst | 2 + document_page_approval/readme/USAGE.rst | 8 + .../static/description/index.html | 449 ++++++++++++++++++ .../tests/test_document_page_approval.py | 3 + .../views/document_page_approval.xml | 4 +- 10 files changed, 549 insertions(+), 50 deletions(-) create mode 100644 document_page_approval/readme/CONFIGURE.rst create mode 100644 document_page_approval/readme/CONTRIBUTORS.rst create mode 100644 document_page_approval/readme/DESCRIPTION.rst create mode 100644 document_page_approval/readme/USAGE.rst create mode 100644 document_page_approval/static/description/index.html diff --git a/document_page_approval/README.rst b/document_page_approval/README.rst index 21b0cc54..1d47bf63 100644 --- a/document_page_approval/README.rst +++ b/document_page_approval/README.rst @@ -1,76 +1,101 @@ -.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg - :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html - :alt: License: AGPL-3 - ====================== Document Page Approval ====================== -This module adds a workflow to approve page modifications and show the approved version by default. +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -Installation -============ +.. |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/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 + :target: https://github.com/OCA/knowledge/tree/12.0/document_page_approval + :alt: OCA/knowledge +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/knowledge-12-0/knowledge-12-0-document_page_approval + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/118/12.0 + :alt: Try me on Runbot -No specific installation required. +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module adds a workflow to approve page modifications +and show the approved version by default. + +**Table of contents** + +.. contents:: + :local: Configuration ============= -* Set a valid email address on the company settings. -* Go to Knowledge > Categories. -* Create a new page category and set an approver group. Make sure users belonging to that group have valid email - addresses. +To configure this module, you need to: + +#. Set a valid email address on the company settings. +#. Go to Knowledge > Categories. +#. Create a new page category and set an approver group. + Make sure users belonging to that group have valid email addresses. Usage ===== To use this module, you need to: -* Go to Knowledge > Pages -* Create a new page and choose the previously created category. -* A notification is sent to the approvers group with a link to the page history to review. -* Depending on the review, the page history is approved or not. -* Users reading the page see the last approved version. - -.. 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 -====================== - +#. Go to Knowledge > Pages +#. Create a new page and choose the previously created category. +#. A notification is sent to the approvers group with a link to the + page history to review. +#. Depending on the review, the page history is approved or not. +#. Users reading the page see the last approved version. Bug Tracker =========== -Bugs are tracked on `GitHub Issues `_. +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 smashing it by providing a detailed and welcomed feedback `here `_. +If you spotted it first, help us smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. Credits ======= +Authors +~~~~~~~ + +* Savoir-faire Linux + Contributors ------------- +~~~~~~~~~~~~ * Odoo SA * Savoir-faire Linux * Gervais Naoussi * Maxime Chambreuil * Iván Todorovich +* Victor M.M. Torres -Maintainer ----------- - -.. image:: https://odoo-community.org/logo.png - :alt: Odoo Community Association - :target: https://odoo-community.org +Maintainers +~~~~~~~~~~~ This module is maintained by the OCA. +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. -To contribute to this module, please visit https://odoo-community.org. +This module is part of the `OCA/knowledge `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/document_page_approval/__manifest__.py b/document_page_approval/__manifest__.py index 13307c48..170391bd 100644 --- a/document_page_approval/__manifest__.py +++ b/document_page_approval/__manifest__.py @@ -3,7 +3,7 @@ { 'name': 'Document Page Approval', - 'version': '11.0.2.1.0', + 'version': '12.0.1.0.0', "author": "Savoir-faire Linux, Odoo Community Association (OCA)", "website": "http://www.savoirfairelinux.com", "license": "AGPL-3", diff --git a/document_page_approval/models/document_page_history.py b/document_page_approval/models/document_page_history.py index fd9bfc96..f836050b 100644 --- a/document_page_approval/models/document_page_history.py +++ b/document_page_approval/models/document_page_history.py @@ -85,7 +85,7 @@ class DocumentPageHistory(models.Model): users = self.env['res.users'].search([ ('groups_id', 'in', guids), ('groups_id', 'in', approver_gid.id)]) - rec.message_subscribe_users([u.id for u in users]) + rec.message_subscribe([u.id for u in users]) rec.message_post_with_template(template.id) else: # auto-approve if approval is not required @@ -102,9 +102,9 @@ class DocumentPageHistory(models.Model): raise UserError(_( 'You are not authorized to do this.\r\n' 'Only approvers with these groups can approve this: ' - ) % ', '.join( - [g.display_name - for g in rec.page_id.approver_group_ids])) + ) % ', '.join( + [g.display_name + for g in rec.page_id.approver_group_ids])) # Update state rec.write({ 'state': 'approved', @@ -118,14 +118,14 @@ class DocumentPageHistory(models.Model): subtype='mt_comment', body=_( 'Change request has been approved by %s.' - ) % (self.env.user.name) + ) % (self.env.user.name) ) # Notify followers a new version is available rec.page_id.message_post( subtype='mt_comment', body=_( 'New version of the document %s approved.' - ) % (rec.page_id.name) + ) % (rec.page_id.name) ) @api.multi @@ -137,8 +137,8 @@ class DocumentPageHistory(models.Model): subtype='mt_comment', body=_( 'Change request %s has been cancelled by %s.' - ) % (rec.display_name, self.env.user.name) - ) + ) % (rec.display_name, self.env.user.name) + ) @api.multi def action_cancel_and_draft(self): @@ -167,7 +167,7 @@ class DocumentPageHistory(models.Model): base_url, self.env.cr.dbname, page.id - ) + ) @api.multi def _compute_diff(self): @@ -181,6 +181,6 @@ class DocumentPageHistory(models.Model): domain.append(('approved_date', '<', rec.approved_date)) prev = history.search(domain, limit=1, order='approved_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) diff --git a/document_page_approval/readme/CONFIGURE.rst b/document_page_approval/readme/CONFIGURE.rst new file mode 100644 index 00000000..1a123ecd --- /dev/null +++ b/document_page_approval/readme/CONFIGURE.rst @@ -0,0 +1,6 @@ +To configure this module, you need to: + +#. Set a valid email address on the company settings. +#. Go to Knowledge > Categories. +#. Create a new page category and set an approver group. + Make sure users belonging to that group have valid email addresses. diff --git a/document_page_approval/readme/CONTRIBUTORS.rst b/document_page_approval/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000..0e72ccdc --- /dev/null +++ b/document_page_approval/readme/CONTRIBUTORS.rst @@ -0,0 +1,6 @@ +* Odoo SA +* Savoir-faire Linux +* Gervais Naoussi +* Maxime Chambreuil +* Iván Todorovich +* Victor M.M. Torres diff --git a/document_page_approval/readme/DESCRIPTION.rst b/document_page_approval/readme/DESCRIPTION.rst new file mode 100644 index 00000000..be1ab22e --- /dev/null +++ b/document_page_approval/readme/DESCRIPTION.rst @@ -0,0 +1,2 @@ +This module adds a workflow to approve page modifications +and show the approved version by default. diff --git a/document_page_approval/readme/USAGE.rst b/document_page_approval/readme/USAGE.rst new file mode 100644 index 00000000..6fb71147 --- /dev/null +++ b/document_page_approval/readme/USAGE.rst @@ -0,0 +1,8 @@ +To use this module, you need to: + +#. Go to Knowledge > Pages +#. Create a new page and choose the previously created category. +#. A notification is sent to the approvers group with a link to the + page history to review. +#. Depending on the review, the page history is approved or not. +#. Users reading the page see the last approved version. diff --git a/document_page_approval/static/description/index.html b/document_page_approval/static/description/index.html new file mode 100644 index 00000000..4bdeca25 --- /dev/null +++ b/document_page_approval/static/description/index.html @@ -0,0 +1,449 @@ + + + + + + +Document Page Approval + + + +
+

Document Page Approval

+ + +

Beta License: AGPL-3 OCA/knowledge Translate me on Weblate Try me on Runbot

+

This module adds a workflow to approve page modifications +and show the approved version by default.

+

Table of contents

+ +
+

Configuration

+

To configure this module, you need to:

+
    +
  1. Set a valid email address on the company settings.
  2. +
  3. Go to Knowledge > Categories.
  4. +
  5. Create a new page category and set an approver group. +Make sure users belonging to that group have valid email addresses.
  6. +
+
+
+

Usage

+

To use this module, you need to:

+
    +
  1. Go to Knowledge > Pages
  2. +
  3. Create a new page and choose the previously created category.
  4. +
  5. A notification is sent to the approvers group with a link to the +page history to review.
  6. +
  7. Depending on the review, the page history is approved or not.
  8. +
  9. Users reading the page see the last approved version.
  10. +
+
+
+

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 smashing it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Savoir-faire Linux
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

This module is part of the OCA/knowledge project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/document_page_approval/tests/test_document_page_approval.py b/document_page_approval/tests/test_document_page_approval.py index 12cdfdbf..f41cc6ef 100644 --- a/document_page_approval/tests/test_document_page_approval.py +++ b/document_page_approval/tests/test_document_page_approval.py @@ -12,6 +12,9 @@ class TestDocumentPageApproval(common.TransactionCase): self.page1 = self.env.ref('document_page.demo_page1') self.approver_gid = self.env.ref( 'document_page_approval.group_document_approver_user') + self.env.ref('base.user_root').write({ + 'groups_id': [(4, self.approver_gid.id)], + }) # demo_approval self.category2 = self.page_obj.create({ 'name': 'This category requires approval', diff --git a/document_page_approval/views/document_page_approval.xml b/document_page_approval/views/document_page_approval.xml index 610ce4de..105c73e5 100644 --- a/document_page_approval/views/document_page_approval.xml +++ b/document_page_approval/views/document_page_approval.xml @@ -183,10 +183,10 @@ - + - +