Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ addon | version | maintainers | summary
[document_page](document_page/) | 18.0.2.1.0 | | Document Page
[document_page_access_group](document_page_access_group/) | 18.0.1.0.1 | | Choose groups to access document pages
[document_page_access_group_user_role](document_page_access_group_user_role/) | 18.0.1.0.0 | <a href='https://github.com/victoralmau'><img src='https://github.com/victoralmau.png' width='32' height='32' style='border-radius:50%;' alt='victoralmau'/></a> | Document Page Access Group User Role
[document_page_approval](document_page_approval/) | 18.0.1.1.0 | | Document Page Approval
[document_page_approval](document_page_approval/) | 18.0.1.1.1 | | Document Page Approval
[document_page_group](document_page_group/) | 18.0.1.0.0 | | Define access groups on documents
[document_page_partner](document_page_partner/) | 18.0.1.0.0 | | Allows to link doucment pages to a partner
[document_page_project](document_page_project/) | 18.0.1.0.0 | <a href='https://github.com/LoisRForgeFlow'><img src='https://github.com/LoisRForgeFlow.png' width='32' height='32' style='border-radius:50%;' alt='LoisRForgeFlow'/></a> | This module links document pages to projects
Expand Down
2 changes: 1 addition & 1 deletion document_page_approval/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Document Page Approval
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:ad1f0f3942df59076ffe4ebdf9ba440842d2792c5a1932cfd434ce9f20448e87
!! source digest: sha256:076e3494c42033cf34cf3d9a7a92ea7f0d7982d04738360bec6ff9604ee1b357
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
Expand Down
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": "18.0.1.1.0",
"version": "18.0.1.1.1",
"author": "Savoir-faire Linux, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/knowledge",
"license": "AGPL-3",
Expand Down
6 changes: 5 additions & 1 deletion document_page_approval/models/document_page_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from odoo import fields, models
from odoo.exceptions import UserError
from odoo.tools.misc import clean_context
from odoo.tools.translate import _


Expand Down Expand Up @@ -80,7 +81,10 @@ def action_to_approve(self):
[("groups_id", "in", guids), ("groups_id", "in", approver_gid.id)]
)
rec.message_subscribe(partner_ids=users.mapped("partner_id").ids)
rec.message_post_with_source(template)
# pylint: disable=W8121
rec.with_context(
clean_context(self.env.context)
).message_post_with_source(template)
else:
# auto-approve if approval is not required
rec.action_approve()
Expand Down
2 changes: 1 addition & 1 deletion document_page_approval/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ <h1>Document Page Approval</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:ad1f0f3942df59076ffe4ebdf9ba440842d2792c5a1932cfd434ce9f20448e87
!! source digest: sha256:076e3494c42033cf34cf3d9a7a92ea7f0d7982d04738360bec6ff9604ee1b357
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<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/license-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
Expand Down
9 changes: 9 additions & 0 deletions document_page_approval/tests/test_document_page_approval.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from odoo import Command
from odoo.exceptions import UserError
from odoo.tests import new_test_user
from odoo.tools import mute_logger

from odoo.addons.base.tests.common import BaseCommon

Expand Down Expand Up @@ -53,6 +54,7 @@ def test_approval_required(self):
self.assertTrue(page.has_changes_pending_approval)
self.assertEqual(len(page.history_ids), 0)

@mute_logger("odoo.models.unlink")
def test_change_request_approve(self):
"""Test that an approver can approve a change request."""
page = self.page2
Expand All @@ -72,6 +74,11 @@ def test_change_request_approve(self):
self.assertEqual(chreq.state, "approved")
self.assertEqual(chreq.content, page.content)

# Remove the linked mail.message and define a specific context to simulate that
# when accessing from the category smart button, there is no error when creating
# the history and sending the email
self.env["mail.message"].browse(page.parent_id.id).unlink()
page = page.with_context(default_parent_id=page.parent_id.id)
# Create new change request
page.write({"content": "<p>New content</p>"})
page.invalidate_model() # Recompute fields
Expand All @@ -90,6 +97,7 @@ def test_change_request_auto_approve(self):
page.write({"content": "<p>New content</p>"})
self.assertEqual(page.content, "<p>New content</p>")

@mute_logger("odoo.models.unlink")
def test_change_request_from_scratch(self):
"""Test a full change request lifecycle from draft to approval."""
page = self.page2
Expand Down Expand Up @@ -164,6 +172,7 @@ def test_can_user_approve_this_page(self):
self.page2.with_user(self.user2).can_user_approve_this_page(self.user2)
)

@mute_logger("odoo.models.unlink")
def test_pending_approval_detection(self):
"""Ensure the system detects pending approval changes"""
# Reset page2 by removing previous history
Expand Down