Skip to content

Commit 743d95d

Browse files
committed
Merge PR #509 into 17.0
Signed-off-by pedrobaeza
2 parents 827fc0d + 6438cd2 commit 743d95d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+29453
-7
lines changed

document_page/models/document_page_history.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,7 @@ def _get_diff(self, v1, v2):
6666
context=True,
6767
)
6868

69-
# TODO: Replace for _compute_display_name
70-
def name_get(self):
71-
return [(rec.id, "%s #%i" % (rec.page_id.name, rec.id)) for rec in self]
72-
73-
@api.depends("page_id")
69+
@api.depends("page_id", "page_id.name")
7470
def _compute_display_name(self):
7571
for rec in self:
76-
rec.display_name = rec.id, "%s #%i" % (rec.page_id.name, rec.id)
72+
rec.display_name = f"{rec.page_id.name} #{rec.id}"

document_page/security/document_page_security.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@
1212
<field name="name">Manager</field>
1313
<field name="category_id" ref="document_knowledge.module_category_knowledge" />
1414
<field name="implied_ids" eval="[(4, ref('group_document_editor'))]" />
15-
<field name="users" eval="[(4, ref('base.user_admin'))]" />
15+
<field
16+
name="users"
17+
eval="[(4, ref('base.user_root')), (4, ref('base.user_admin'))]"
18+
/>
1619
</record>
1720
<record model="ir.rule" id="document_page_rule">
1821
<field name="name">document_page multi-company</field>

document_page_approval/README.rst

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
======================
2+
Document Page Approval
3+
======================
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:eaa85b29d79372636ce9dda9fbf87f567e6702f38a57385384a168b28a517ff5
11+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12+
13+
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
14+
:target: https://odoo-community.org/page/development-status
15+
:alt: Beta
16+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
17+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
18+
:alt: License: AGPL-3
19+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fknowledge-lightgray.png?logo=github
20+
:target: https://github.com/OCA/knowledge/tree/17.0/document_page_approval
21+
:alt: OCA/knowledge
22+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23+
:target: https://translation.odoo-community.org/projects/knowledge-17-0/knowledge-17-0-document_page_approval
24+
:alt: Translate me on Weblate
25+
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/knowledge&target_branch=17.0
27+
:alt: Try me on Runboat
28+
29+
|badge1| |badge2| |badge3| |badge4| |badge5|
30+
31+
This module adds a workflow to approve page modifications and show the
32+
approved version by default.
33+
34+
**Table of contents**
35+
36+
.. contents::
37+
:local:
38+
39+
Configuration
40+
=============
41+
42+
To configure this module, you need to:
43+
44+
1. Set a valid email address on the company settings.
45+
2. Go to Knowledge > Categories.
46+
3. Create a new page category and set an approver group. Make sure users
47+
belonging to that group have valid email addresses.
48+
49+
Usage
50+
=====
51+
52+
To use this module, you need to:
53+
54+
1. Go to Knowledge > Pages
55+
2. Create a new page and choose the previously created category.
56+
3. A notification is sent to the approvers group with a link to the page
57+
history to review.
58+
4. Depending on the review, the page history is approved or not.
59+
5. Users reading the page see the last approved version.
60+
61+
Bug Tracker
62+
===========
63+
64+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/knowledge/issues>`_.
65+
In case of trouble, please check there if your issue has already been reported.
66+
If you spotted it first, help us to smash it by providing a detailed and welcomed
67+
`feedback <https://github.com/OCA/knowledge/issues/new?body=module:%20document_page_approval%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
68+
69+
Do not contact contributors directly about support or help with technical issues.
70+
71+
Credits
72+
=======
73+
74+
Authors
75+
-------
76+
77+
* Savoir-faire Linux
78+
79+
Contributors
80+
------------
81+
82+
- Odoo SA <info@odoo.com>
83+
84+
- Savoir-faire Linux <support@savoirfairelinux.com>
85+
86+
- Gervais Naoussi <gervaisnaoussi@gmail.com>
87+
88+
- Maxime Chambreuil <mchambreuil@opensourceintegrators.com>
89+
90+
- Iván Todorovich <ivan.todorovich@gmail.com>
91+
92+
- `Tecnativa <https://www.tecnativa.com>`__:
93+
94+
- Victor M.M. Torres
95+
- Víctor Martínez
96+
97+
- `Guadaltech <https://www.guadaltech.es>`__:
98+
99+
- Fernando La Chica <fernando.lachica@guadaltech.es>
100+
101+
Maintainers
102+
-----------
103+
104+
This module is maintained by the OCA.
105+
106+
.. image:: https://odoo-community.org/logo.png
107+
:alt: Odoo Community Association
108+
:target: https://odoo-community.org
109+
110+
OCA, or the Odoo Community Association, is a nonprofit organization whose
111+
mission is to support the collaborative development of Odoo features and
112+
promote its widespread use.
113+
114+
This module is part of the `OCA/knowledge <https://github.com/OCA/knowledge/tree/17.0/document_page_approval>`_ project on GitHub.
115+
116+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

document_page_approval/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Copyright (C) 2013 Savoir-faire Linux (<http://www.savoirfairelinux.com>).
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
3+
4+
from . import models
5+
from .hooks import post_init_hook, uninstall_hook
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Copyright (C) 2013 Savoir-faire Linux (<http://www.savoirfairelinux.com>).
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
3+
4+
{
5+
"name": "Document Page Approval",
6+
"version": "17.0.1.0.0",
7+
"author": "Savoir-faire Linux, Odoo Community Association (OCA)",
8+
"website": "https://github.com/OCA/knowledge",
9+
"license": "AGPL-3",
10+
"category": "Knowledge Management",
11+
"depends": ["document_page", "mail"],
12+
"data": [
13+
"data/email_template.xml",
14+
"views/document_page_approval.xml",
15+
"security/document_page_security.xml",
16+
],
17+
"images": [
18+
"images/category.png",
19+
"images/page_history_list.png",
20+
"images/page_history.png",
21+
],
22+
"post_init_hook": "post_init_hook",
23+
"uninstall_hook": "uninstall_hook",
24+
"installable": True,
25+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<odoo>
3+
<!-- If user wants to make upgrade-proof customizations to email templates, he should edit ir.model.data and check noupdate himself -->
4+
<record id="email_template_new_draft_need_approval" model="mail.template">
5+
<field name="name">Automated new draft need approval Notification Mail</field>
6+
<field
7+
name="email_from"
8+
>{{object.create_uid.company_id.email or 'noreply@localhost.com'}}</field>
9+
<field
10+
name="subject"
11+
>New version of {{object.display_name}} needs your approval</field>
12+
<field name="model_id" ref="model_document_page_history" />
13+
<field name="auto_delete" eval="True" />
14+
<field name="lang">{{object.create_uid.partner_id.lang}}</field>
15+
<field name="body_html" type="html">
16+
<p>Hello,</p>
17+
<p><t t-out="object.create_uid.name" /> submited a new Change Request for <b
18+
t-out="object.page_id.name"
19+
/> and it needs your approval.</p>
20+
<h1>
21+
<a t-att-href="object.page_url" t-out="object.display_name" />
22+
</h1>
23+
<p><b>Modified by:</b> <t t-out="object.create_uid.name" /></p>
24+
<p><b>Date:</b> <t t-out="object.create_date" /></p>
25+
<t t-if="object.summary">
26+
<h3>Summary</h3>
27+
<p t-out="object.summary" />
28+
</t>
29+
<h3>Diff</h3>
30+
<div style="overflow-x:scroll; font-size:0.85em; margin-bottom:2em;">
31+
<t t-out="object.diff" />
32+
</div>
33+
<p>Have a great day.</p>
34+
<br />
35+
<p>Odoo</p>
36+
</field>
37+
</record>
38+
</odoo>

document_page_approval/hooks.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Copyright 2018 Ivan Todorovich (<ivan.todorovich@gmail.com>)
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
3+
import logging
4+
5+
_logger = logging.getLogger(__name__)
6+
7+
8+
def post_init_hook(env): # pragma: no cover
9+
# Set all pre-existing pages history to approved
10+
_logger.info("Setting history to approved.")
11+
env.cr.execute(
12+
"""
13+
UPDATE document_page_history
14+
SET state='approved',
15+
approved_uid=create_uid,
16+
approved_date=create_date
17+
WHERE state IS NULL OR state = 'draft'
18+
"""
19+
)
20+
21+
22+
def uninstall_hook(env): # pragma: no cover
23+
# Remove unapproved pages
24+
_logger.info("Deleting unapproved Change Requests.")
25+
env.cr.execute("DELETE FROM document_page_history WHERE state != 'approved'")

0 commit comments

Comments
 (0)