From a57b007362a172ee3ed18c1d613c168a9c734870 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Aur=C3=A9lien=20Calonne?= <aurel@nexedi.com>
Date: Mon, 3 Jul 2006 09:00:55 +0000
Subject: [PATCH] 2006-07-03 aurel * update generic fast input script

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@8277 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 ...Delivery_generateCashDetailInputDialog.xml |  3 ++-
 .../CashDetail_saveFastInputLine.xml          | 25 ++++++++++++++-----
 .../Delivery_getMovementList.xml              |  2 ++
 3 files changed, 23 insertions(+), 7 deletions(-)

diff --git a/bt5/erp5_banking_core/SkinTemplateItem/portal_skins/erp5_banking_core/CashDelivery_generateCashDetailInputDialog.xml b/bt5/erp5_banking_core/SkinTemplateItem/portal_skins/erp5_banking_core/CashDelivery_generateCashDetailInputDialog.xml
index f4c57ada6b..9ac3036645 100644
--- a/bt5/erp5_banking_core/SkinTemplateItem/portal_skins/erp5_banking_core/CashDelivery_generateCashDetailInputDialog.xml
+++ b/bt5/erp5_banking_core/SkinTemplateItem/portal_skins/erp5_banking_core/CashDelivery_generateCashDetailInputDialog.xml
@@ -359,7 +359,8 @@ else :\n
     # compute the price for existing line\n
     quantity = 0\n
     for column_nb in xrange(1, len(column_base_list) + 1):\n
-      quantity += line[\'column%s\' %(str(column_nb))]\n
+      if line[\'column%s\' %(str(column_nb))] != \'\' and line[\'column%s\' %(str(column_nb))] is not None:\n
+        quantity += line[\'column%s\' %(str(column_nb))]\n
     line[\'price\'] = resource_price * quantity\n
     total_price += line[\'price\']\n
     # add current line\n
diff --git a/bt5/erp5_banking_core/SkinTemplateItem/portal_skins/erp5_banking_core/CashDetail_saveFastInputLine.xml b/bt5/erp5_banking_core/SkinTemplateItem/portal_skins/erp5_banking_core/CashDetail_saveFastInputLine.xml
index c765e0ac7a..9a5a419654 100644
--- a/bt5/erp5_banking_core/SkinTemplateItem/portal_skins/erp5_banking_core/CashDetail_saveFastInputLine.xml
+++ b/bt5/erp5_banking_core/SkinTemplateItem/portal_skins/erp5_banking_core/CashDetail_saveFastInputLine.xml
@@ -167,6 +167,7 @@ for line in listbox:\n
         per_resource_dict[resource_id] = {movement_key:movement,}\n
 \n
 # create the movement\n
+variation_not_defined = 0\n
 for resource_id in per_resource_dict.keys():\n
   variation_list_dict = per_resource_dict[resource_id].values()\n
   # get the resource\n
@@ -186,7 +187,8 @@ for resource_id in per_resource_dict.keys():\n
     # check if variation exist for the resource\n
     if column_base_category == "variation":\n
       if variation != \'variation/not_defined\' and variation.lstrip(\'variation/\') not in resource_object.getVariationList():\n
-        raise "InputError",  "%s doesn\\\'t  exist for %s" %(resource_object.getTitle(), variation)\n
+        variation_not_defined = 1\n
+        break\n
     if not emission_letter_dict.has_key(letter):\n
       emission_letter_dict[letter] = 1\n
     if not cash_status_dict.has_key(status):\n
@@ -250,12 +252,22 @@ for resource_id in per_resource_dict.keys():\n
       else:\n
         cell.setQuantity(variation_item["quantity"])\n
 \n
-\n
-request  = context.REQUEST\n
-redirect_url = \'%s/view?%s\' % ( context.absolute_url()\n
-                                , \'portal_status_message=Lines Created\'\n
+if variation_not_defined:\n
+  old_line = [x.getObject() for x in context.Delivery_getMovementList(portal_type=[line_portal_type,])]\n
+  if len(old_line)>0:\n
+    for object_list in old_line:\n
+      context.deleteContent(object_list.getId())\n
+  request  = context.REQUEST\n
+  redirect_url = \'%s/view?%s\' % ( context.absolute_url()\n
+                                , "portal_status_message=%s doesn\\\'t  exist for %s" %(resource_object.getTitle(), variation)\n
                                 )\n
-request[ \'RESPONSE\' ].redirect( redirect_url )\n
+  request[ \'RESPONSE\' ].redirect( redirect_url )\n
+else:\n
+  request  = context.REQUEST\n
+  redirect_url = \'%s/view?%s\' % ( context.absolute_url()\n
+                                  , \'portal_status_message=Lines Created\'\n
+                                  )\n
+  request[ \'RESPONSE\' ].redirect( redirect_url )\n
 
 
 ]]></string> </value>
@@ -354,6 +366,7 @@ request[ \'RESPONSE\' ].redirect( redirect_url )\n
                             <string>_write_</string>
                             <string>movement_key</string>
                             <string>resource_id</string>
+                            <string>variation_not_defined</string>
                             <string>variation_list_dict</string>
                             <string>resource_list</string>
                             <string>resource_object</string>
diff --git a/bt5/erp5_banking_core/SkinTemplateItem/portal_skins/erp5_banking_core/Delivery_getMovementList.xml b/bt5/erp5_banking_core/SkinTemplateItem/portal_skins/erp5_banking_core/Delivery_getMovementList.xml
index f500b07424..ec645f7beb 100644
--- a/bt5/erp5_banking_core/SkinTemplateItem/portal_skins/erp5_banking_core/Delivery_getMovementList.xml
+++ b/bt5/erp5_banking_core/SkinTemplateItem/portal_skins/erp5_banking_core/Delivery_getMovementList.xml
@@ -86,6 +86,8 @@ if len(line_list) == 0:\n
   invert = 1\n
 if len(line_list) == 0:\n
   return []\n
+if len(portal_type) == 1:\n
+  return line_list\n
 cell_list = []\n
 for line in line_list:\n
   if invert:\n
-- 
2.30.9