Browse Source

[FIX] Readme.rst & optimise exception search

pull/775/head
Mourad Elhadj Mimoune 8 years ago
parent
commit
b17e95da69
  1. 21
      base_exception/README.rst
  2. 14
      base_exception/models/base_exception.py

21
base_exception/README.rst

@ -3,36 +3,30 @@
:alt: License: AGPL-3 :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 Usage
===== =====
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot :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 Bug Tracker
=========== ===========
Bugs are tracked on `GitHub Issues Bugs are tracked on `GitHub Issues
<https://github.com/OCA/sale-workflow/issues>`_. In case of trouble, please
<https://github.com/OCA/server-tools/issues>`_. In case of trouble, please
check there if your issue has already been reported. If you spotted it first, 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 help us smashing it by providing a detailed and welcomed `feedback
<https://github.com/OCA/ <https://github.com/OCA/
sale-workflow/issues/new?body=module:%20
sale_exception%0Aversion:%20
9.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
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 Images
------ ------
@ -48,6 +42,7 @@ Contributors
* Guewen Baconnier <guewen.baconnier@camptocamp.com> * Guewen Baconnier <guewen.baconnier@camptocamp.com>
* Yannick Vaucher <yannick.vaucher@camptocamp.com> * Yannick Vaucher <yannick.vaucher@camptocamp.com>
* SodexisTeam <dev@sodexis.com> * SodexisTeam <dev@sodexis.com>
* Mourad EL HADJ MIMOUNE <mourad.elhadj.mimoune@akretion.com>
Maintainer Maintainer
---------- ----------

14
base_exception/models/base_exception.py

@ -34,7 +34,7 @@ class ExceptionRule(models.Model):
help="Gives the sequence order when applying the test") help="Gives the sequence order when applying the test")
rule_group = fields.Selection( 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: " "at same time for a target object. Ex: "
"validate sale.order.line rules with sale order rules.", "validate sale.order.line rules with sale order rules.",
required=True) required=True)
@ -139,12 +139,12 @@ class BaseException(models.AbstractModel):
"""returns the list of exception_ids for all the considered base.exceptions """returns the list of exception_ids for all the considered base.exceptions
""" """
exception_obj = self.env['exception.rule'] 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 = [] all_exception_ids = []
for obj in self: for obj in self:

Loading…
Cancel
Save