From c549080cc49b86a7ff3815ef6264161abd0edb18 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com>
Date: Wed, 16 Apr 2008 09:05:37 +0000
Subject: [PATCH] test if the tax rule will actually do something before
 applying it

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@20557 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5/Document/TaxRule.py | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/product/ERP5/Document/TaxRule.py b/product/ERP5/Document/TaxRule.py
index 48b01d256f..00bb44a5b9 100644
--- a/product/ERP5/Document/TaxRule.py
+++ b/product/ERP5/Document/TaxRule.py
@@ -105,3 +105,13 @@ class TaxRule(DeliveryRule):
     # Pass to base class
     Rule.expand(self, applied_rule, force=force, **kw)
 
+  def test(self, context, *args, **kw):
+    """Test if this rule can be applied.
+
+    We return false immediatly if the rule won't create any simulation
+    movement, to prevent creating an empty applied rule.
+    """
+    if not (context.DeliveryMovement_getCorrespondingTaxLineList()):
+      return False
+    return DeliveryRule.test(self, context, *args, **kw)
+
-- 
2.30.9