From ee215ee79d998048aae1e6261daf7b73d058b403 Mon Sep 17 00:00:00 2001 From: Ivan Todorovich Date: Tue, 18 Jun 2019 10:34:05 +0000 Subject: [PATCH] [IMP] Add convenience action to ignore exceptions on record [IMP] Computed exception descriptions field, to display better help messages [IMP] Exceptions shouldn't be copied --- base_exception/README.rst | 2 +- base_exception/__manifest__.py | 2 +- base_exception/models/base_exception.py | 24 +++++++++++++++++++++++- base_exception/readme/CONTRIBUTORS.rst | 2 +- 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/base_exception/README.rst b/base_exception/README.rst index af86936b6..77de77e40 100644 --- a/base_exception/README.rst +++ b/base_exception/README.rst @@ -75,7 +75,7 @@ Contributors * SodexisTeam * Mourad EL HADJ MIMOUNE * Raphaël Reverdy -* Iván Todorovich +* Iván Todorovich Maintainers ~~~~~~~~~~~ diff --git a/base_exception/__manifest__.py b/base_exception/__manifest__.py index 579801eef..1abe02f59 100644 --- a/base_exception/__manifest__.py +++ b/base_exception/__manifest__.py @@ -4,7 +4,7 @@ # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). { 'name': 'Exception Rule', - 'version': '12.0.2.0.3', + 'version': '12.0.3.0.0', 'category': 'Generic Modules', 'summary': """ This module provide an abstract model to manage customizable diff --git a/base_exception/models/base_exception.py b/base_exception/models/base_exception.py index 26c4b57c4..006b2fc24 100644 --- a/base_exception/models/base_exception.py +++ b/base_exception/models/base_exception.py @@ -4,6 +4,7 @@ # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). import time +import html from odoo import api, fields, models, _ from odoo.exceptions import UserError, ValidationError from odoo.tools.safe_eval import safe_eval @@ -191,9 +192,22 @@ class BaseException(models.AbstractModel): string='Main Exception', store=True, ) - exception_ids = fields.Many2many('exception.rule', string='Exceptions') + exceptions_summary = fields.Html( + 'Exceptions Summary', + compute='_compute_exceptions_summary', + ) + exception_ids = fields.Many2many( + 'exception.rule', + string='Exceptions', + copy=False, + ) ignore_exception = fields.Boolean('Ignore Exceptions', copy=False) + @api.multi + def action_ignore_exceptions(self): + self.write({'ignore_exception': True}) + return True + @api.depends('exception_ids', 'ignore_exception') def _compute_main_error(self): for rec in self: @@ -202,6 +216,14 @@ class BaseException(models.AbstractModel): else: rec.main_exception_id = False + @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 = '
    %s
' % ''.join([ + '
  • %s: %s
  • ' % tuple(map(html.escape, ( + e.name, e.description))) for e in rec.exception_ids]) + @api.multi def _popup_exceptions(self): action = self._get_popup_action().read()[0] diff --git a/base_exception/readme/CONTRIBUTORS.rst b/base_exception/readme/CONTRIBUTORS.rst index 6a3fc650e..89e9f3f29 100644 --- a/base_exception/readme/CONTRIBUTORS.rst +++ b/base_exception/readme/CONTRIBUTORS.rst @@ -6,4 +6,4 @@ * SodexisTeam * Mourad EL HADJ MIMOUNE * Raphaël Reverdy -* Iván Todorovich +* Iván Todorovich