From f36c3dfa40894e8f708e9022cd8702cbbcaed007 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com>
Date: Fri, 2 Nov 2007 13:47:23 +0000
Subject: [PATCH] Get the price currency from the packing list, then from the
 order if not found on packing list

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@17362 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 ...oiceTransaction_postGenerationActivity.xml | 23 ++++++++++++-------
 bt5/erp5_accounting/bt/revision               |  2 +-
 2 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/InvoiceTransaction_postGenerationActivity.xml b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/InvoiceTransaction_postGenerationActivity.xml
index 52a7c62e12..83f62fa313 100644
--- a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/InvoiceTransaction_postGenerationActivity.xml
+++ b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/InvoiceTransaction_postGenerationActivity.xml
@@ -90,14 +90,20 @@ invoice.Delivery_setCausalityFromSimulation()\n
 related_packing_list = invoice.getDefaultCausalityValue()\n
 #LOG(\'causality %s \' %invoice.getCausalityValueList())\n
 \n
-# get a price_currency from the packing list\n
-related_order  = related_packing_list.getDefaultCausalityValue()\n
-if related_order is not None:\n
-  price_currency = related_order.getPriceCurrency()\n
+# XXX this use of currency is completly bogus, it should be set on simulation movements.\n
+# get a price_currency from the packing list, or the order\n
+price_currency = related_packing_list.getPriceCurrency()\n
+if price_currency:\n
   invoice.edit(\n
-    resource = price_currency,\n
-    price_currency = price_currency,\n
-  )\n
+       resource=price_currency,\n
+       price_currency=price_currency,)\n
+else:\n
+  related_order = related_packing_list.getDefaultCausalityValue()\n
+  if related_order is not None:\n
+    price_currency = related_order.getPriceCurrency()\n
+    invoice.edit(\n
+       resource=price_currency,\n
+       price_currency=price_currency,)\n
   \n
 # copy title, if not updating a new delivery\n
 if not invoice.getTitle():\n
@@ -113,6 +119,7 @@ if invoice.getSimulationState() == \'draft\':\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.plan()\n
@@ -178,9 +185,9 @@ invoice.activate(\n
                             <string>LOG</string>
                             <string>_getattr_</string>
                             <string>related_packing_list</string>
+                            <string>price_currency</string>
                             <string>related_order</string>
                             <string>None</string>
-                            <string>price_currency</string>
                             <string>e</string>
                           </tuple>
                         </value>
diff --git a/bt5/erp5_accounting/bt/revision b/bt5/erp5_accounting/bt/revision
index 8cb9d84396..941d0e591f 100644
--- a/bt5/erp5_accounting/bt/revision
+++ b/bt5/erp5_accounting/bt/revision
@@ -1 +1 @@
-475
\ No newline at end of file
+479
\ No newline at end of file
-- 
2.30.9