From 230fe3eb4f137ec907244ace5528c4558679b3c9 Mon Sep 17 00:00:00 2001
From: Kazuhiko Shiozaki <kazuhiko@nexedi.com>
Date: Wed, 12 Oct 2011 13:53:08 +0200
Subject: [PATCH] Fix the issue that a Invoice document can wrongly have a
 needless Root Applied Rule when it is created by Delivery Builder with a site
 which has many activity nodes.

---
 .../InvoiceTransaction_postGeneration.xml            | 12 +++++++++---
 bt5/erp5_invoicing/bt/change_log                     |  3 +++
 bt5/erp5_invoicing/bt/revision                       |  2 +-
 3 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/bt5/erp5_invoicing/SkinTemplateItem/portal_skins/erp5_invoicing/InvoiceTransaction_postGeneration.xml b/bt5/erp5_invoicing/SkinTemplateItem/portal_skins/erp5_invoicing/InvoiceTransaction_postGeneration.xml
index 32d2c8aa80..a996eae073 100644
--- a/bt5/erp5_invoicing/SkinTemplateItem/portal_skins/erp5_invoicing/InvoiceTransaction_postGeneration.xml
+++ b/bt5/erp5_invoicing/SkinTemplateItem/portal_skins/erp5_invoicing/InvoiceTransaction_postGeneration.xml
@@ -119,18 +119,24 @@ if not invoice.hasTitle() and related_packing_list.hasTitle():\n
   invoice.setTitle(related_packing_list.getTitle())\n
 \n
 # initialize accounting_workflow to confirmed state\n
+confirm_tag = \'%s_confirm\' % invoice.getPath()\n
 if invoice.getSimulationState() == \'draft\':\n
-  invoice.confirm(comment=translateString(\'Initialised by Delivery Builder.\'),)\n
+  invoice.activate(after_path_and_method_id=(related_simulation_movement_path_list,\n
+  (\'immediateReindexObject\',\'recursiveImmediateReindexObject\')),\n
+  tag=confirm_tag).Delivery_confirm()\n
 else:\n
   # call builder just same as after script of \'confirm\' transition\n
-  invoice.Delivery_expandAndBuild()\n
+  invoice.activate(after_path_and_method_id=(related_simulation_movement_path_list,\n
+  (\'immediateReindexObject\',\'recursiveImmediateReindexObject\')),\n
+  tag=confirm_tag).Delivery_expandAndBuild()\n
 \n
 # First set the invoice in the building state on the causality workflow\n
 invoice.startBuilding()\n
 \n
 # Then an activity should put the causality state in diverged or solved\n
 invoice.activate(after_path_and_method_id=(related_simulation_movement_path_list,\n
-  (\'immediateReindexObject\',\'recursiveImmediateReindexObject\'))).updateCausalityState()\n
+  (\'immediateReindexObject\',\'recursiveImmediateReindexObject\')),\n
+  after_tag=confirm_tag).updateCausalityState()\n
 
 
 ]]></string> </value>
diff --git a/bt5/erp5_invoicing/bt/change_log b/bt5/erp5_invoicing/bt/change_log
index 590adae8fd..66c8113bf2 100644
--- a/bt5/erp5_invoicing/bt/change_log
+++ b/bt5/erp5_invoicing/bt/change_log
@@ -1,3 +1,6 @@
+2011-10-12 Kazuhiko
+* Fix the issue that a Invoice document can wrongly have a needless Root Applied Rule when it is created by Delivery Builder with a site which has many activity nodes.
+
 2011-07-25 Kazuhiko
 * add grand_grand_parent_specialise_reference related key.
 
diff --git a/bt5/erp5_invoicing/bt/revision b/bt5/erp5_invoicing/bt/revision
index 9361cf7165..1c34b96390 100644
--- a/bt5/erp5_invoicing/bt/revision
+++ b/bt5/erp5_invoicing/bt/revision
@@ -1 +1 @@
-376
\ No newline at end of file
+377
\ No newline at end of file
-- 
2.30.9