Browse Source

[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
12.0
Ivan Todorovich 5 years ago
committed by Iván Todorovich
parent
commit
ee215ee79d
  1. 2
      base_exception/README.rst
  2. 2
      base_exception/__manifest__.py
  3. 24
      base_exception/models/base_exception.py
  4. 2
      base_exception/readme/CONTRIBUTORS.rst

2
base_exception/README.rst

@ -75,7 +75,7 @@ Contributors
* SodexisTeam <dev@sodexis.com>
* Mourad EL HADJ MIMOUNE <mourad.elhadj.mimoune@akretion.com>
* Raphaël Reverdy <raphael.reverdy@akretion.com>
* Iván Todorovich <ivan.todorovich@gmail.com>
* Iván Todorovich <ivan.todorovich@druidoo.io>
Maintainers
~~~~~~~~~~~

2
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

24
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 = '<ul>%s</ul>' % ''.join([
'<li>%s: <i>%s</i></li>' % 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]

2
base_exception/readme/CONTRIBUTORS.rst

@ -6,4 +6,4 @@
* SodexisTeam <dev@sodexis.com>
* Mourad EL HADJ MIMOUNE <mourad.elhadj.mimoune@akretion.com>
* Raphaël Reverdy <raphael.reverdy@akretion.com>
* Iván Todorovich <ivan.todorovich@gmail.com>
* Iván Todorovich <ivan.todorovich@druidoo.io>
Loading…
Cancel
Save