diff --git a/base_exception/README.rst b/base_exception/README.rst index 96b838ccf..3a85ea5a5 100644 --- a/base_exception/README.rst +++ b/base_exception/README.rst @@ -3,36 +3,30 @@ :alt: License: AGPL-3 ============== -Sale Exception +Base Exception ============== -This module allows you attach several customizable exceptions to your -sale order in a way that you can filter orders by exceptions type and fix them. - -This is especially useful in an scenario for mass sales order import such as -with the base_sale_multi_channels module, because it's likely some orders have -errors when you import them (like product not found in Odoo, wrong line -format etc.) +This module provide an abstract model to manage customizable exceptions to be applied on different models (sale order, invoice, ...). It is not usefull for itself. You can see an exemple of implementation in the 'sale_exception' module. (sale-workflow repository). Usage ===== .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas :alt: Try me on Runbot - :target: https://runbot.odoo-community.org/runbot/167/9.0 + :target: https://runbot.odoo-community.org/runbot/167/10.0 Bug Tracker =========== Bugs are tracked on `GitHub Issues -`_. In case of trouble, please +`_. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us smashing it by providing a detailed and welcomed `feedback `_. +server-tools/issues/new?body=module:%20 +base_exception%0Aversion:%20 +10.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. Images ------ @@ -48,6 +42,7 @@ Contributors * Guewen Baconnier * Yannick Vaucher * SodexisTeam +* Mourad EL HADJ MIMOUNE Maintainer ---------- diff --git a/base_exception/models/base_exception.py b/base_exception/models/base_exception.py index 1503e40d9..573298f7e 100644 --- a/base_exception/models/base_exception.py +++ b/base_exception/models/base_exception.py @@ -34,7 +34,7 @@ class ExceptionRule(models.Model): help="Gives the sequence order when applying the test") rule_group = fields.Selection( [], - help="Rule group is used the group the rules that must validated " + help="Rule group is used to group the rules that must validated " "at same time for a target object. Ex: " "validate sale.order.line rules with sale order rules.", required=True) @@ -139,12 +139,12 @@ class BaseException(models.AbstractModel): """returns the list of exception_ids for all the considered base.exceptions """ exception_obj = self.env['exception.rule'] - model_exceptions = exception_obj.sudo().search( - [('model', '=', self._name)]) - sub_exceptions = exception_obj.sudo().search( - [('rule_group', '=', self.rule_group), - ('id', 'not in', model_exceptions.ids), - ]) + all_exceptions = exception_obj.sudo().search( + [('rule_group', '=', self[0].rule_group)]) + model_exceptions = all_exceptions.filtered( + lambda ex: ex.model == self._name) + sub_exceptions = all_exceptions.filtered( + lambda ex: ex.model != self._name) all_exception_ids = [] for obj in self: