[FIX] base_exception_user: fix stack trace when exception description is False

H7674
This commit is contained in:
Cedric Collins
2021-09-24 10:49:03 -05:00
parent 2dc6ab1424
commit 7e42315e69
2 changed files with 19 additions and 2 deletions

View File

@@ -1,7 +1,24 @@
from odoo import models, fields import html
from odoo import api, models, fields
class ExceptionRule(models.Model): class ExceptionRule(models.Model):
_inherit = 'exception.rule' _inherit = 'exception.rule'
allow_user_ignore = fields.Boolean('Allow User Ignore') allow_user_ignore = fields.Boolean('Allow User Ignore')
class BaseException(models.AbstractModel):
_inherit = 'base.exception'
@api.depends("exception_ids", "ignore_exception")
def _compute_exceptions_summary(self):
for rec in self:
if rec.exception_ids and not rec.ignore_exception:
rec.exceptions_summary = "<ul>%s</ul>" % "".join(
[
"<li>%s: <i>%s</i></li>"
% tuple(map(html.escape, (e.name, e.description or '')))
for e in rec.exception_ids
]
)

View File

@@ -16,7 +16,7 @@ class ExceptionRuleConfirm(models.AbstractModel):
def action_confirm(self): def action_confirm(self):
if self.ignore and 'message_ids' in self.related_model_id: if self.ignore and 'message_ids' in self.related_model_id:
exceptions_summary = '<ul>%s</ul>' % ''.join( exceptions_summary = '<ul>%s</ul>' % ''.join(
['<li>%s: <i>%s</i></li>' % tuple(map(html.escape, (e.name, e.description))) for e in ['<li>%s: <i>%s</i></li>' % tuple(map(html.escape, (e.name, e.description or ''))) for e in
self.exception_ids]) self.exception_ids])
msg = '<p><strong>Exceptions ignored:</strong></p>' + exceptions_summary msg = '<p><strong>Exceptions ignored:</strong></p>' + exceptions_summary
self.related_model_id.message_post(body=msg) self.related_model_id.message_post(body=msg)