11from odoo import Command
22from odoo .exceptions import UserError
33from odoo .tests import new_test_user
4+ from odoo .tools import mute_logger
45
56from odoo .addons .base .tests .common import BaseCommon
67
@@ -53,6 +54,7 @@ def test_approval_required(self):
5354 self .assertTrue (page .has_changes_pending_approval )
5455 self .assertEqual (len (page .history_ids ), 0 )
5556
57+ @mute_logger ("odoo.models.unlink" )
5658 def test_change_request_approve (self ):
5759 """Test that an approver can approve a change request."""
5860 page = self .page2
@@ -72,6 +74,11 @@ def test_change_request_approve(self):
7274 self .assertEqual (chreq .state , "approved" )
7375 self .assertEqual (chreq .content , page .content )
7476
77+ # Remove the linked mail.message and define a specific context to simulate that
78+ # when accessing from the category smart button, there is no error when creating
79+ # the history and sending the email
80+ self .env ["mail.message" ].browse (page .parent_id .id ).unlink ()
81+ page = page .with_context (default_parent_id = page .parent_id .id )
7582 # Create new change request
7683 page .write ({"content" : "<p>New content</p>" })
7784 page .invalidate_model () # Recompute fields
@@ -90,6 +97,7 @@ def test_change_request_auto_approve(self):
9097 page .write ({"content" : "<p>New content</p>" })
9198 self .assertEqual (page .content , "<p>New content</p>" )
9299
100+ @mute_logger ("odoo.models.unlink" )
93101 def test_change_request_from_scratch (self ):
94102 """Test a full change request lifecycle from draft to approval."""
95103 page = self .page2
@@ -164,6 +172,7 @@ def test_can_user_approve_this_page(self):
164172 self .page2 .with_user (self .user2 ).can_user_approve_this_page (self .user2 )
165173 )
166174
175+ @mute_logger ("odoo.models.unlink" )
167176 def test_pending_approval_detection (self ):
168177 """Ensure the system detects pending approval changes"""
169178 # Reset page2 by removing previous history
0 commit comments