Skip to content
Open
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 base_exception/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
{
"name": "Exception Rule",
"version": "18.0.1.1.1",
"version": "18.0.1.1.2",
"development_status": "Mature",
"category": "Generic Modules",
"summary": """
Expand Down
7 changes: 7 additions & 0 deletions base_exception/tests/test_base_exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,13 @@ def test_blocking_exception(self):
with self.assertRaises(UserError):
self.po.action_ignore_exceptions()
self.assertFalse(self.po.ignore_exception)
# The confirmation wizard must enforce the same blocking check, even
# when a downstream wizard sets ``ignore_exception`` directly.
self.exception_rule_confirm.exception_ids = self.po.exception_ids
self.exception_rule_confirm.ignore = True
with self.assertRaises(UserError):
self.exception_rule_confirm.action_confirm()
self.assertFalse(self.po.ignore_exception)
with self.assertRaises(ValidationError):
self.po.button_confirm()
self.po.with_context(raise_exception=False).button_confirm()
Expand Down
11 changes: 10 additions & 1 deletion base_exception/wizard/base_exception_confirm.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Copyright 2020 Hibou Corp.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import _, api, fields, models
from odoo.exceptions import ValidationError
from odoo.exceptions import UserError, ValidationError


class ExceptionRuleConfirm(models.AbstractModel):
Expand Down Expand Up @@ -34,4 +34,13 @@ def default_get(self, field_list):

def action_confirm(self):
self.ensure_one()
if self.ignore:
if any(self.exception_ids.mapped("is_blocking")):
raise UserError(
_(
"The exceptions can not be ignored, because "
"some of them are blocking."
)
)
self.related_model_id.action_ignore_exceptions()
return {"type": "ir.actions.act_window_close"}
Loading