Skip to content

Commit

Permalink
Merge 984a52a into 493b337
Browse files Browse the repository at this point in the history
  • Loading branch information
Victor Martin committed Aug 23, 2019
2 parents 493b337 + 984a52a commit 1381fa8
Show file tree
Hide file tree
Showing 92 changed files with 22,285 additions and 0 deletions.
101 changes: 101 additions & 0 deletions document_page_approval/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
======================
Document Page Approval
======================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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

|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
=============

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.

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 smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/knowledge/issues/new?body=module:%20document_page_approval%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

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

Credits
=======

Authors
~~~~~~~

* Savoir-faire Linux

Contributors
~~~~~~~~~~~~

* Odoo SA <info@odoo.com>
* Savoir-faire Linux <support@savoirfairelinux.com>
* Gervais Naoussi <gervaisnaoussi@gmail.com>
* Maxime Chambreuil <mchambreuil@opensourceintegrators.com>
* Iván Todorovich <ivan.todorovich@gmail.com>
* Victor M.M. Torres <victor.martin@tecnativa.com>

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.

This module is part of the `OCA/knowledge <https://github.com/OCA/knowledge/tree/12.0/document_page_approval>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
5 changes: 5 additions & 0 deletions document_page_approval/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Copyright (C) 2013 Savoir-faire Linux (<http://www.savoirfairelinux.com>).
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import models
from .hooks import post_init_hook, uninstall_hook
29 changes: 29 additions & 0 deletions document_page_approval/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright (C) 2013 Savoir-faire Linux (<http://www.savoirfairelinux.com>).
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
'name': 'Document Page Approval',
'version': '12.0.1.0.0',
"author": "Savoir-faire Linux, Odoo Community Association (OCA)",
"website": "http://www.savoirfairelinux.com",
"license": "AGPL-3",
'category': 'Knowledge Management',
'depends': [
'document_page',
'mail',
],
'data': [
'data/email_template.xml',
'views/document_page_approval.xml',
'security/document_page_security.xml',
'security/ir.model.access.csv',
],
'images': [
'images/category.png',
'images/page_history_list.png',
'images/page_history.png',
],
'post_init_hook': 'post_init_hook',
'uninstall_hook': 'uninstall_hook',
'installable': True,
}
43 changes: 43 additions & 0 deletions document_page_approval/data/email_template.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0"?>
<odoo>

<!-- If user wants to make upgrade-proof customizations to email templates, he should edit ir.model.data and check noupdate himself -->
<record id="email_template_new_draft_need_approval" model="mail.template">
<field name="name">Automated new draft need approval Notification Mail</field>
<field name="email_from">${object.create_uid.company_id.email or 'noreply@localhost.com'}</field>
<field name="subject">New version of ${object.display_name} needs your approval</field>
<field name="model_id" ref="model_document_page_history"/>
<field name="auto_delete" eval="True"/>
<field name="lang">${object.create_uid.partner_id.lang}</field>
<field name="body_html">
<![CDATA[
<p>Hello,</p>
<p>${object.create_uid.name} submited a new Change Request for <b>${object.page_id.name}</b> and it needs your approval.</p>
<h1><a href="${object.page_url}">${object.display_name}</a></h1>
<p>
<b>Modified by:</b> ${object.create_uid.name}<br/>
<b>Date:</b> ${object.create_date}<br>
</p>
% if object.summary:
<h3>Summary</h3>
<p>${object.summary}</p>
% endif
<h3>Diff</h3>
<div style="overflow-x:scroll; font-size:0.85em; margin-bottom:2em;">
${object.diff|safe}
</div>
<p>Have a great day.</p>
--<br/>
<p>Odoo</p>
]]>
</field>
</record>

</odoo>
25 changes: 25 additions & 0 deletions document_page_approval/hooks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright 2018 Ivan Todorovich (<ivan.todorovich@gmail.com>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import logging
_logger = logging.getLogger(__name__)


def post_init_hook(cr, registry): # pragma: no cover
# Set all pre-existing pages history to approved
_logger.info('Setting history to approved.')
cr.execute("""
UPDATE document_page_history
SET state='approved',
approved_uid=create_uid,
approved_date=create_date
WHERE state IS NULL OR state = 'draft'
""")


def uninstall_hook(cr, registry): # pragma: no cover
# Remove unapproved pages
_logger.info('Deleting unapproved Change Requests.')
cr.execute(
"DELETE FROM document_page_history "
"WHERE state != 'approved'"
)

0 comments on commit 1381fa8

Please sign in to comment.