diff --git a/base_exception/models/base_exception.py b/base_exception/models/base_exception.py index 0eb552b48..2bbb5c32b 100644 --- a/base_exception/models/base_exception.py +++ b/base_exception/models/base_exception.py @@ -42,6 +42,9 @@ class ExceptionRule(models.Model): help="Python code executed to check if the exception apply or " "not. Use failed = True to block the exception", ) + is_blocking = fields.Boolean( + string="Is blocking", help="When checked the exception can not be ignored", + ) @api.constrains("exception_type", "domain", "code") def check_exception_type_consistency(self): @@ -201,6 +204,13 @@ class BaseExceptionModel(models.AbstractModel): ignore_exception = fields.Boolean("Ignore Exceptions", copy=False) def action_ignore_exceptions(self): + if any(self.exception_ids.mapped("is_blocking")): + raise UserError( + _( + "The exceptions can not be ignored, because " + "some of them are blocking." + ) + ) self.write({"ignore_exception": True}) return True @@ -218,8 +228,17 @@ class BaseExceptionModel(models.AbstractModel): if rec.exception_ids and not rec.ignore_exception: rec.exceptions_summary = "" % "".join( [ - "
  • %s: %s
  • " - % tuple(map(html.escape, (e.name, e.description or ""))) + "
  • %s: %s %s
  • " + % tuple( + map( + html.escape, + ( + e.name, + e.description or "", + _("(Blocking exception)") if e.is_blocking else "", + ), + ) + ) for e in rec.exception_ids ] ) diff --git a/base_exception/views/base_exception_view.xml b/base_exception/views/base_exception_view.xml index cf894605b..876b9db01 100644 --- a/base_exception/views/base_exception_view.xml +++ b/base_exception/views/base_exception_view.xml @@ -49,6 +49,7 @@ widget="domain" options="{'model': 'model'}" /> +