From dcc93a7e6cc2c8c405f51c375e32719380771b9f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C5=81ukasz=20Nowak?= <luke@nexedi.com>
Date: Thu, 21 Jan 2010 16:42:10 +0000
Subject: [PATCH]  - confirm invoice "unconditionally"

Post building script shall work in all possible cases.

Catching only WorkflowException was in consistent:

 * user without privileges in accounting was able to build invoice coming from
   packing list without price currency (script worked well)
 * user with privileges in accounting, which delivered packing list, was not
   able to confirm this invoice, as ValidationFailed was raised


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@31889 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 .../InvoiceTransaction_postGeneration.xml         | 15 +--------------
 bt5/erp5_invoicing/bt/revision                    |  2 +-
 2 files changed, 2 insertions(+), 15 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 14362acf89..dc1e0d56d7 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
@@ -105,19 +105,7 @@ if not invoice.hasTitle() and related_packing_list.hasTitle():\n
 \n
 # initialize accounting_workflow to confirmed state\n
 if invoice.getSimulationState() == \'draft\':\n
-  try :\n
-    context.getPortalObject().portal_workflow.doActionFor(\n
-      invoice, \'confirm_action\',\n
-      comment=translateString(\'Initialised by Delivery Builder.\'),\n
-      skip_period_validation=1)\n
-  except WorkflowException, e:\n
-    # The user cannot pass the transition, it\'s OK\n
-    pass\n
-\n
-  if invoice.getSimulationState() == \'draft\':\n
-    # call the workflow method, if the user cannot perform this operation.\n
-    invoice.confirm(comment=translateString(\'Initialised by Delivery Builder.\'),)\n
-\n
+  invoice.confirm(comment=translateString(\'Initialised by Delivery Builder.\'),)\n
 \n
 # First set the invoice in the building state on the causality workflow\n
 invoice.startBuilding()\n
@@ -184,7 +172,6 @@ invoice.activate(after_path_and_method_id=(related_simulation_movement_path_list
                             <string>order_trade_model_line_copy_id_list</string>
                             <string>order_trade_model_line</string>
                             <string>clipboard</string>
-                            <string>e</string>
                           </tuple>
                         </value>
                     </item>
diff --git a/bt5/erp5_invoicing/bt/revision b/bt5/erp5_invoicing/bt/revision
index 5f1a9f39c2..f9c94c8318 100644
--- a/bt5/erp5_invoicing/bt/revision
+++ b/bt5/erp5_invoicing/bt/revision
@@ -1 +1 @@
-324
\ No newline at end of file
+325
\ No newline at end of file
-- 
2.30.9