Skip to content

Commit

Permalink
[MIG] document_page_approval: Migration to 18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
BhaveshHeliconia committed Feb 17, 2025
1 parent c5b98da commit 9233be7
Show file tree
Hide file tree
Showing 7 changed files with 212 additions and 87 deletions.
34 changes: 19 additions & 15 deletions document_page_approval/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ Document Page Approval
: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/17.0/document_page_approval
:target: https://github.com/OCA/knowledge/tree/18.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-17-0/knowledge-17-0-document_page_approval
:target: https://translation.odoo-community.org/projects/knowledge-18-0/knowledge-18-0-document_page_approval
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/knowledge&target_branch=17.0
:target: https://runboat.odoo-community.org/builds?repo=OCA/knowledge&target_branch=18.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|
Expand Down Expand Up @@ -64,7 +64,7 @@ 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 to smash it by providing a detailed and welcomed
`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**>`_.
`feedback <https://github.com/OCA/knowledge/issues/new?body=module:%20document_page_approval%0Aversion:%2018.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.

Expand All @@ -79,24 +79,28 @@ Authors
Contributors
------------

- Odoo SA <[email protected]>
- Odoo SA <[email protected]>

- Savoir-faire Linux <[email protected]>
- Savoir-faire Linux <[email protected]>

- Gervais Naoussi <[email protected]>
- Gervais Naoussi <[email protected]>

- Maxime Chambreuil <[email protected]>
- Maxime Chambreuil <[email protected]>

- Iván Todorovich <[email protected]>
- Iván Todorovich <[email protected]>

- `Tecnativa <https://www.tecnativa.com>`__:
- `Tecnativa <https://www.tecnativa.com>`__:

- Victor M.M. Torres
- Víctor Martínez
- Victor M.M. Torres
- Víctor Martínez

- `Guadaltech <https://www.guadaltech.es>`__:
- `Guadaltech <https://www.guadaltech.es>`__:

- Fernando La Chica <[email protected]>
- Fernando La Chica <[email protected]>

- `Heliconia Solutions Pvt. Ltd. <https://www.heliconia.io>`__

- Bhavesh Heliconia

Maintainers
-----------
Expand All @@ -111,6 +115,6 @@ 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/17.0/document_page_approval>`_ project on GitHub.
This module is part of the `OCA/knowledge <https://github.com/OCA/knowledge/tree/18.0/document_page_approval>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 1 addition & 1 deletion document_page_approval/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

{
"name": "Document Page Approval",
"version": "17.0.1.0.0",
"version": "18.0.1.0.0",
"author": "Savoir-faire Linux, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/knowledge",
"license": "AGPL-3",
Expand Down
22 changes: 15 additions & 7 deletions document_page_approval/models/document_page_history.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Copyright (C) 2013 Savoir-faire Linux (<http://www.savoirfairelinux.com>).
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

import re

from odoo import fields, models
from odoo.exceptions import UserError
from odoo.tools.translate import _
Expand Down Expand Up @@ -93,12 +95,14 @@ def action_approve(self):
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]
"Only approvers with these groups can approve this: {}"
).format(
", ".join(
[g.display_name for g in rec.page_id.approver_group_ids]
)
)
)

# Update state
rec.write(
{
Expand Down Expand Up @@ -156,14 +160,18 @@ def _compute_page_url(self):
)

def _compute_diff(self):
"""Shows a diff between this version and the previous version"""
"""Shows a cleaned-up diff between this version and the previous version."""
history = self.env["document.page.history"]
for rec in self:
domain = [("page_id", "=", rec.page_id.id), ("state", "=", "approved")]
if rec.approved_date:
domain.append(("approved_date", "<", rec.approved_date))
prev = history.search(domain, limit=1, order="approved_date DESC")
if prev:
rec.diff = self._get_diff(prev.id, rec.id)
raw_diff = self._get_diff(prev.id, rec.id)
else:
rec.diff = self._get_diff(False, rec.id)
raw_diff = self._get_diff(False, rec.id)

cleaned_diff = re.sub(r'data-last-history-steps=".*?"', "", raw_diff)

rec.diff = cleaned_diff
2 changes: 2 additions & 0 deletions document_page_approval/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@
- [Guadaltech](https://www.guadaltech.es):

- Fernando La Chica \<<[email protected]>\>
- [Heliconia Solutions Pvt. Ltd.](https://www.heliconia.io)
- Bhavesh Heliconia
11 changes: 8 additions & 3 deletions document_page_approval/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ <h1 class="title">Document Page Approval</h1>
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:4b3ef803acd19a66515436d838c979c63daecf130c34b3f628dd5d8ac8137d34
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/knowledge/tree/17.0/document_page_approval"><img alt="OCA/knowledge" src="https://img.shields.io/badge/github-OCA%2Fknowledge-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/knowledge-17-0/knowledge-17-0-document_page_approval"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/knowledge&amp;target_branch=17.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/knowledge/tree/18.0/document_page_approval"><img alt="OCA/knowledge" src="https://img.shields.io/badge/github-OCA%2Fknowledge-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/knowledge-18-0/knowledge-18-0-document_page_approval"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/knowledge&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module adds a workflow to approve page modifications and show the
approved version by default.</p>
<p><strong>Table of contents</strong></p>
Expand Down Expand Up @@ -413,7 +413,7 @@ <h1><a class="toc-backref" href="#toc-entry-3">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/knowledge/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
<a class="reference external" href="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**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/knowledge/issues/new?body=module:%20document_page_approval%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
Expand Down Expand Up @@ -450,6 +450,11 @@ <h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
<li>Fernando La Chica &lt;<a class="reference external" href="mailto:fernando.lachica&#64;guadaltech.es">fernando.lachica&#64;guadaltech.es</a>&gt;</li>
</ul>
</li>
<li><p class="first"><a class="reference external" href="https://www.heliconia.io">Heliconia Solutions Pvt. Ltd.</a></p>
<ul class="simple">
<li>Bhavesh Heliconia</li>
</ul>
</li>
</ul>
</div>
<div class="section" id="maintainers">
Expand All @@ -461,7 +466,7 @@ <h2><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h2>
<p>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.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/knowledge/tree/17.0/document_page_approval">OCA/knowledge</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/knowledge/tree/18.0/document_page_approval">OCA/knowledge</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
Expand Down
Loading

0 comments on commit 9233be7

Please sign in to comment.