diff --git a/base_exception_user/__init__.py b/base_exception_user/__init__.py new file mode 100644 index 00000000..9b429614 --- /dev/null +++ b/base_exception_user/__init__.py @@ -0,0 +1,2 @@ +from . import models +from . import wizard diff --git a/base_exception_user/__manifest__.py b/base_exception_user/__manifest__.py new file mode 100644 index 00000000..ec5728b4 --- /dev/null +++ b/base_exception_user/__manifest__.py @@ -0,0 +1,24 @@ +# Part of Hibou Suite Professional. See LICENSE_PROFESSIONAL file for full copyright and licensing details. + +{ + 'name': 'Exception Rule User', + 'version': '12.0.1.0.0', + 'author': 'Hibou Corp.', + 'license': 'OPL-1', + 'category': 'Generic Modules', + 'summary': 'Allow users to ignore exceptions', + 'description': """ +Allow users to ignore exceptions +""", + 'website': 'https://hibou.io/', + 'depends': [ + 'base_exception', + ], + 'data': [ + 'security/base_exception_security.xml', + 'views/base_exception_views.xml', + 'wizard/base_exception_confirm_view.xml', + ], + 'installable': True, + 'auto_install': False, +} diff --git a/base_exception_user/models/__init__.py b/base_exception_user/models/__init__.py new file mode 100644 index 00000000..495e1fe2 --- /dev/null +++ b/base_exception_user/models/__init__.py @@ -0,0 +1 @@ +from . import base_exception diff --git a/base_exception_user/models/base_exception.py b/base_exception_user/models/base_exception.py new file mode 100644 index 00000000..46453bce --- /dev/null +++ b/base_exception_user/models/base_exception.py @@ -0,0 +1,7 @@ +from odoo import models, fields + + +class ExceptionRule(models.Model): + _inherit = 'exception.rule' + + allow_user_ignore = fields.Boolean('Allow User Ignore') diff --git a/base_exception_user/security/base_exception_security.xml b/base_exception_user/security/base_exception_security.xml new file mode 100644 index 00000000..0dfbf591 --- /dev/null +++ b/base_exception_user/security/base_exception_security.xml @@ -0,0 +1,13 @@ + + + + + Exception user + + + + + + + + diff --git a/base_exception_user/views/base_exception_views.xml b/base_exception_user/views/base_exception_views.xml new file mode 100644 index 00000000..08e5f6b1 --- /dev/null +++ b/base_exception_user/views/base_exception_views.xml @@ -0,0 +1,26 @@ + + + + + exception.rule.tree.inherit.user + exception.rule + + + + + + + + + + exception.rule.form.inherit.user + exception.rule + + + + + + + + + diff --git a/base_exception_user/wizard/__init__.py b/base_exception_user/wizard/__init__.py new file mode 100644 index 00000000..a31f679e --- /dev/null +++ b/base_exception_user/wizard/__init__.py @@ -0,0 +1 @@ +from . import base_exception_confirm diff --git a/base_exception_user/wizard/base_exception_confirm.py b/base_exception_user/wizard/base_exception_confirm.py new file mode 100644 index 00000000..80b18073 --- /dev/null +++ b/base_exception_user/wizard/base_exception_confirm.py @@ -0,0 +1,36 @@ +import html +from odoo import api, fields, models + + +class ExceptionRuleConfirm(models.AbstractModel): + _inherit = 'exception.rule.confirm' + + show_ignore_button = fields.Boolean('Allow User Ignore', compute='_compute_show_ignore_button') + + @api.depends('exception_ids') + def _compute_show_ignore_button(self): + for wiz in self: + wiz.show_ignore_button = (self.env.user.has_group('base_exception_user.group_exception_rule_user') and + all(wiz.exception_ids.mapped('allow_user_ignore'))) + + def action_confirm(self): + if self.ignore and 'message_ids' in self.related_model_id: + exceptions_summary = '' % ''.join( + ['
  • %s: %s
  • ' % tuple(map(html.escape, (e.name, e.description))) for e in + self.exception_ids]) + msg = '

    Exceptions ignored:

    ' + exceptions_summary + self.related_model_id.message_post(body=msg) + return super().action_confirm() + + + def action_ignore(self): + self.ensure_one() + if self.show_ignore_button: + if 'message_ids' in self.related_model_id: + msg = '

    Exceptions ignored:

    ' + self.related_model_id.exceptions_summary + self.related_model_id.message_post(body=msg) + return self._action_ignore() + return False + + def _action_ignore(self): + return {'type': 'ir.actions.act_window_close'} diff --git a/base_exception_user/wizard/base_exception_confirm_view.xml b/base_exception_user/wizard/base_exception_confirm_view.xml new file mode 100644 index 00000000..4252ff15 --- /dev/null +++ b/base_exception_user/wizard/base_exception_confirm_view.xml @@ -0,0 +1,18 @@ + + + + + Exceptions Rules + exception.rule.confirm + + + + + + +