From 863cfd4d888ca706e0107432a9328b17fe52e8f0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com>
Date: Wed, 28 Jan 2009 10:41:14 +0000
Subject: [PATCH] in the default configuration, we should only build the
 invoice related to the packing list that have been started/stopped

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@25324 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 .../scripts/PurchasePackingList_buildInvoice.xml         | 8 ++++++--
 .../scripts/SalePackingList_buildInvoice.xml             | 9 +++++++--
 bt5/erp5_trade/bt/revision                               | 2 +-
 3 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/bt5/erp5_trade/WorkflowTemplateItem/portal_workflow/packing_list_workflow/scripts/PurchasePackingList_buildInvoice.xml b/bt5/erp5_trade/WorkflowTemplateItem/portal_workflow/packing_list_workflow/scripts/PurchasePackingList_buildInvoice.xml
index 426ad01a43..5e11778fc1 100644
--- a/bt5/erp5_trade/WorkflowTemplateItem/portal_workflow/packing_list_workflow/scripts/PurchasePackingList_buildInvoice.xml
+++ b/bt5/erp5_trade/WorkflowTemplateItem/portal_workflow/packing_list_workflow/scripts/PurchasePackingList_buildInvoice.xml
@@ -58,6 +58,9 @@ packing_list = sci[\'object\']\n
 delivery_tool = sci.getPortal().portal_deliveries\n
 \n
 if packing_list.getPortalType() == \'Purchase Packing List\':\n
+  explanation_uid = packing_list.getCausalityUid(\n
+                         portal_type=\'Purchase Order\') or packing_list.getUid()\n
+\n
   tag = \'build_invoice_%s\' % packing_list.getRelativeUrl()\n
   # WARNING: this tag is also used in InvoiceTransaction_postGeneration script\n
   tax_tag = \'build_invoice_tax_%s\' % packing_list.getRelativeUrl()\n
@@ -71,7 +74,7 @@ if packing_list.getPortalType() == \'Purchase Packing List\':\n
                               \'recursiveImmediateReindexObject\',\n
                               \'updateAppliedRule\',\n
                               \'immediateReindexObject\' ],\n
-          ).build()\n
+          ).build(explanation_uid=explanation_uid)\n
   else:\n
     log(\'no purchase_invoice_builder found\')\n
 \n
@@ -84,7 +87,7 @@ if packing_list.getPortalType() == \'Purchase Packing List\':\n
                               \'recursiveImmediateReindexObject\',\n
                               \'updateAppliedRule\',\n
                               \'immediateReindexObject\' ],\n
-          ).build()\n
+          ).build(explanation_uid=explanation_uid)\n
   else:\n
     log(\'no purchase_invoice_tax_builder found\')\n
 </string> </value>
@@ -130,6 +133,7 @@ if packing_list.getPortalType() == \'Purchase Packing List\':\n
                             <string>packing_list</string>
                             <string>_getattr_</string>
                             <string>delivery_tool</string>
+                            <string>explanation_uid</string>
                             <string>tag</string>
                             <string>tax_tag</string>
                             <string>getattr</string>
diff --git a/bt5/erp5_trade/WorkflowTemplateItem/portal_workflow/packing_list_workflow/scripts/SalePackingList_buildInvoice.xml b/bt5/erp5_trade/WorkflowTemplateItem/portal_workflow/packing_list_workflow/scripts/SalePackingList_buildInvoice.xml
index 0721fc056d..cd4afb4349 100644
--- a/bt5/erp5_trade/WorkflowTemplateItem/portal_workflow/packing_list_workflow/scripts/SalePackingList_buildInvoice.xml
+++ b/bt5/erp5_trade/WorkflowTemplateItem/portal_workflow/packing_list_workflow/scripts/SalePackingList_buildInvoice.xml
@@ -56,7 +56,11 @@
             <value> <string>from Products.ERP5Type.Log import log\n
 packing_list = sci[\'object\']\n
 delivery_tool = sci.getPortal().portal_deliveries\n
+\n
 if packing_list.getPortalType() == \'Sale Packing List\':\n
+  explanation_uid = packing_list.getCausalityUid(\n
+                         portal_type=\'Sale Order\') or packing_list.getUid()\n
+\n
   tag = \'build_invoice_%s\' % packing_list.getRelativeUrl()\n
   # WARNING: this tag is also used in InvoiceTransaction_postGeneration script\n
   tax_tag = \'build_invoice_tax_%s\' % packing_list.getRelativeUrl()\n
@@ -70,7 +74,7 @@ if packing_list.getPortalType() == \'Sale Packing List\':\n
                               \'recursiveImmediateReindexObject\',\n
                               \'updateAppliedRule\',\n
                               \'immediateReindexObject\' ],\n
-          ).build()\n
+          ).build(explanation_uid=explanation_uid)\n
   else:\n
     log(\'no sale_invoice_builder found\')\n
 \n
@@ -83,7 +87,7 @@ if packing_list.getPortalType() == \'Sale Packing List\':\n
                               \'recursiveImmediateReindexObject\',\n
                               \'updateAppliedRule\',\n
                               \'immediateReindexObject\' ],\n
-          ).build()\n
+          ).build(explanation_uid=explanation_uid)\n
   else:\n
     log(\'no sale_invoice_tax_builder found\')\n
 </string> </value>
@@ -129,6 +133,7 @@ if packing_list.getPortalType() == \'Sale Packing List\':\n
                             <string>packing_list</string>
                             <string>_getattr_</string>
                             <string>delivery_tool</string>
+                            <string>explanation_uid</string>
                             <string>tag</string>
                             <string>tax_tag</string>
                             <string>getattr</string>
diff --git a/bt5/erp5_trade/bt/revision b/bt5/erp5_trade/bt/revision
index 99fd4575a5..9d0f8afde3 100644
--- a/bt5/erp5_trade/bt/revision
+++ b/bt5/erp5_trade/bt/revision
@@ -1 +1 @@
-577
\ No newline at end of file
+578
\ No newline at end of file
-- 
2.30.9