From d011a725284597cacefe4e6352161f0248fda500 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Calonne?= <aurel@nexedi.com> Date: Wed, 4 Jun 2008 14:16:28 +0000 Subject: [PATCH] group sql request into one when checking for already loaded references git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@21320 20353a03-c40f-0410-a6d1-a30d3c3de9de --- ...le_importMonetaryReceptionFromCDAction.xml | 31 ++++++++++--------- bt5/erp5_banking_cash/bt/revision | 2 +- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/bt5/erp5_banking_cash/SkinTemplateItem/portal_skins/erp5_banking_cash/MonetaryReceptionModule_importMonetaryReceptionFromCDAction.xml b/bt5/erp5_banking_cash/SkinTemplateItem/portal_skins/erp5_banking_cash/MonetaryReceptionModule_importMonetaryReceptionFromCDAction.xml index 54f1c54b20..9b05ab9550 100644 --- a/bt5/erp5_banking_cash/SkinTemplateItem/portal_skins/erp5_banking_cash/MonetaryReceptionModule_importMonetaryReceptionFromCDAction.xml +++ b/bt5/erp5_banking_cash/SkinTemplateItem/portal_skins/erp5_banking_cash/MonetaryReceptionModule_importMonetaryReceptionFromCDAction.xml @@ -280,6 +280,8 @@ def split_lines(CD_file_line_list):\n CD_line_list = []\n treated_container_list = []\n line_number = 0\n + reference_list = []\n + ref_append = reference_list.append\n for CD_line in CD_file_line_list:\n line_number += 1\n new_CD_line = string.replace(CD_line, \'\\n\', \'\')\n @@ -310,20 +312,21 @@ def split_lines(CD_file_line_list):\n ,\'range_stop\' : line_range_stop\n ,\'quantity\' : line_quantity}\n )\n - # check reference doesn\'t already exist for this resource\n - movement_container_list = context.portal_catalog(portal_type = "Cash Container Item",\n - reference = line_container_id,\n - default_destination_uid = destination_uid,\n - simulation_state = "!=cancelled")\n - # if we find container line with same reference, we must\n - # check the resource defined on line\n - for same_container in movement_container_list:\n - same_container = same_container.getObject()\n - for o in same_container.objectValues():\n - if o.getResourceUid() == resource_value.getUid():\n - #context.log("same containter exist %s" %(o.getPath(), "AURELXXX"))\n - # raise ValueError, "same containter exist %s" %(o.getPath(),)\n - return {\'error\':True, \'message\':message_dict[\'03\'], \'head_dict\':{}}\n + ref_append(line_container_id)\n +\n +\n + # check reference doesn\'t already exist for this resource\n + movement_container_list = context.portal_catalog(portal_type = "Cash Container Item",\n + reference = reference_list,\n + simulation_state = ["empty", "draft", "rejected", "confirmed", "delivered",])\n + # if we find container line with same reference, we must\n + # check the resource defined on line\n + resource_uid = resource_value.getUid()\n + for same_container in movement_container_list:\n + same_container = same_container.getObject()\n + for o in same_container.objectValues():\n + if o.getResourceUid() == resource_uid and o.getDestinationUid() == destination_uid:\n + return {\'error\':True, \'message\':message_dict[\'03\'], \'head_dict\':{}}\n \n \n if line_number > 0:\n diff --git a/bt5/erp5_banking_cash/bt/revision b/bt5/erp5_banking_cash/bt/revision index 5156988895..c8a110e7e8 100644 --- a/bt5/erp5_banking_cash/bt/revision +++ b/bt5/erp5_banking_cash/bt/revision @@ -1 +1 @@ -619 \ No newline at end of file +621 \ No newline at end of file -- 2.30.9