From 218729b663044e335905fdef39222fee59e10322 Mon Sep 17 00:00:00 2001
From: Yoshinori Okuji <yo@nexedi.com>
Date: Tue, 17 Feb 2009 09:30:49 +0000
Subject: [PATCH] Tax Lines should not be accountable inside Accounting
 Transactions, because accounting is done with Accounting Transaction Lines,
 thus the information is added twice in the inventory.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@25591 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5/Document/TaxLine.py | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/product/ERP5/Document/TaxLine.py b/product/ERP5/Document/TaxLine.py
index 616c3b7d6a..e1514c26e7 100644
--- a/product/ERP5/Document/TaxLine.py
+++ b/product/ERP5/Document/TaxLine.py
@@ -64,8 +64,19 @@ class TaxLine(DeliveryLine):
     security.declareProtected(Permissions.AccessContentsInformation,
                               'isAccountable')
     def isAccountable(self):
-      """ """
-      return 1 # XXX not sure
+      """Return true if the parent is accountable and
+      not an accounting transaction.
+
+      NOTE: this is because, if the parent is an accounting transaction,
+      the accounting is done with another accounting transaction line,
+      so making tax lines accountable would duplicate the accounting.
+      """
+      delivery = self.getParentValue()
+      if delivery.isAccountable(): 
+        portal = delivery.getPortalObject()
+        type_list = portal.getPortalAccountingTransactionTypeList()
+        return delivery.getPortalType() not in type_list
+      return 0
 
     security.declareProtected(Permissions.AccessContentsInformation,
                               'hasCellContent')
-- 
2.30.9