From 3a4af252f4fefce2950ad83e3b3c9b4a04b7f628 Mon Sep 17 00:00:00 2001
From: Alexandre Boeglin <alex@nexedi.com>
Date: Tue, 14 Dec 2004 17:27:37 +0000
Subject: [PATCH] Accounting Rule Cell are created in the Invoice
 TransacrionRule Matrix with default Invoice Transaction Lines.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@2009 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5/Document/InvoiceTransactionRule.py | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/product/ERP5/Document/InvoiceTransactionRule.py b/product/ERP5/Document/InvoiceTransactionRule.py
index d059be1fa1..72758aef0e 100755
--- a/product/ERP5/Document/InvoiceTransactionRule.py
+++ b/product/ERP5/Document/InvoiceTransactionRule.py
@@ -105,11 +105,8 @@ class InvoiceTransactionRule(Rule, XMLMatrix):
       if force or \
          (applied_rule.getLastExpandSimulationState() not in applied_rule.getPortalReservedInventoryStateList() and \
          applied_rule.getLastExpandSimulationState() not in applied_rule.getPortalCurrentInventoryStateList()):
-        # First, check each contained movement and make
-        # a list of invoice ids which do not need to be copied
-        # eventually delete movement which do not exist anylonger
-        existing_uid_list = []
 
+        # get the corresponding Cell
         new_kw = (('product_line', my_product_line), ('region', my_destination_region))
         my_cell = my_invoice_transaction_rule.getCellByPredicate(*new_kw) #XXX WARNING ! : my_cell can be None
 
@@ -118,6 +115,11 @@ class InvoiceTransactionRule(Rule, XMLMatrix):
         else :
           my_cell_transaction_id_list = []
 
+        # check each contained movement and make
+        # a list of invoice ids which do not need to be copied
+        # eventually delete movement which do not exist anylonger
+        existing_uid_list = []
+
         for movement in applied_rule.contentValues():
           if movement.getId() in my_cell_transaction_id_list :
             existing_uid_list += [movement.getUid()]
@@ -201,7 +203,9 @@ class InvoiceTransactionRule(Rule, XMLMatrix):
           This method can be overriden
       """
       self.invokeFactory(type_name='Accounting Rule Cell',id=id)
-      return self.get(id)
+      new_cell = self.get(id)
+      new_cell.SaleInvoiceTransaction_init() # This is a site dependant script, it is used to create default invoice transaction lines.
+      return new_cell
 
     security.declareProtected(Permissions.ModifyPortalContent, 'updateMatrix')
     def updateMatrix(self) :
-- 
2.30.9