Commit 1c2b885b authored by Sebastien Robin's avatar Sebastien Robin

- add more cache in CashDelivery_generateCashDetailInputDialog

- add more vault checks in Baobab_checkStockBeforeClosingDate
- add more research in CheckbookModule

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@14720 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 8c012584
...@@ -85,7 +85,8 @@ counter_vault_list = context.Delivery_getVaultItemList(\n ...@@ -85,7 +85,8 @@ counter_vault_list = context.Delivery_getVaultItemList(\n
user_site=0,base_site=site.getRelativeUrl(),all=1,\n user_site=0,base_site=site.getRelativeUrl(),all=1,\n
vault_type=(\'site/surface/banque_interne\',\'site/surface/gros_paiement\',\n vault_type=(\'site/surface/banque_interne\',\'site/surface/gros_paiement\',\n
\'site/surface/gros_versement\',\'site/surface/operations_diverses\',\n \'site/surface/gros_versement\',\'site/surface/operations_diverses\',\n
\'site/surface/salle_tri\'))\n \'site/surface/salle_tri\',\n
\'site/surface/caisse_courante/encaisse_des_devises\'))\n
for counter_vault in counter_vault_list:\n for counter_vault in counter_vault_list:\n
counter_vault_url = counter_vault[1]\n counter_vault_url = counter_vault[1]\n
if counter_vault_url==\'\':\n if counter_vault_url==\'\':\n
......
...@@ -79,13 +79,13 @@ ...@@ -79,13 +79,13 @@
a = a_source.getResourceValue()\n a = a_source.getResourceValue()\n
b = b_source.getResourceValue()\n b = b_source.getResourceValue()\n
\n \n
# First, compare the base prices (such as 1000 and 2000 Francs CFA).\n # Second, compare the portal types.\n
result = - cmp(a.getBasePrice(), b.getBasePrice())\n result = cmp(a.getPortalType(), b.getPortalType())\n
if result != 0:\n if result != 0:\n
return result\n return result\n
\n \n
# Second, compare the portal types.\n # First, compare the base prices (such as 1000 and 2000 Francs CFA).\n
result = cmp(a.getPortalType(), b.getPortalType())\n result = - cmp(a.getBasePrice(), b.getBasePrice())\n
if result != 0:\n if result != 0:\n
return result\n return result\n
\n \n
......
...@@ -71,6 +71,9 @@ ...@@ -71,6 +71,9 @@
# when the user clicks on the Update button, listbox is passed, and\n # when the user clicks on the Update button, listbox is passed, and\n
# the contents must be preserved in the form.\n # the contents must be preserved in the form.\n
\n \n
from Products.ERP5Type.Cache import CachingMethod\n
portal = context.getPortalObject()\n
\n
if listbox is None:\n if listbox is None:\n
# This is the first time.\n # This is the first time.\n
cash_status_list = cash_detail_dict[\'cash_status_list\']\n cash_status_list = cash_detail_dict[\'cash_status_list\']\n
...@@ -140,9 +143,27 @@ if listbox is None:\n ...@@ -140,9 +143,27 @@ if listbox is None:\n
\n \n
# Get the currency cash objects for a given currency.\n # Get the currency cash objects for a given currency.\n
currency = \'currency_module/%s\' % operation_currency\n currency = \'currency_module/%s\' % operation_currency\n
# This is very bad to call catalog each time, it is the bottleneck,\n
# So we will add a caching method here\n
def getCurrencyCashRelativeUrlList(currency=None, currency_cash_portal_type=None):\n
result = context.portal_catalog(portal_type = currency_cash_portal_type)\n result = context.portal_catalog(portal_type = currency_cash_portal_type)\n
currency_cash_list = [x.getObject() for x in result if x.getObject().getPriceCurrency() == currency and len(x.getObject().getVariationList())>0]\n currency_cash_list = [x.getObject() for x in result \n
#context.log(\'CashDelivery_generateCashDetailInputDialog\', \'currency_list = %r, operation_cur = %s\' % (currency_cash_list, operation_currency))\n if x.getObject().getPriceCurrency() == currency \n
and len(x.getObject().getVariationList())>0]\n
return [x.getRelativeUrl() for x in currency_cash_list]\n
getCurrencyCashRelativeUrlList = CachingMethod(getCurrencyCashRelativeUrlList, \n
id=(\'CashDelivery_generateCashDetailInputDialog\', \n
\'getCurrencyCashRelativeUrlList\'), \n
cache_factory=\'erp5_ui_long\')\n
currency_cash_url_list = getCurrencyCashRelativeUrlList(currency=currency,\n
currency_cash_portal_type=currency_cash_portal_type)\n
currency_cash_list = [portal.restrictedTraverse(x) for x in currency_cash_url_list]\n
\n
# This is the same thing, but by using catalog, so this is not nice at all\n
#result = context.portal_catalog(portal_type = currency_cash_portal_type)\n
#currency_cash_list = [x.getObject() for x in result if x.getObject().getPriceCurrency() == currency and len(x.getObject().getVariationList())>0]\n
\n
context.log(\'CashDelivery_generateCashDetailInputDialog\', \'currency_list = %r, operation_cur = %s\' % ([x.getTitle() for x in currency_cash_list], operation_currency))\n
\n \n
# If only one variation is specified, we want to display a part of cash currencies which\n # If only one variation is specified, we want to display a part of cash currencies which\n
# exists in this variation (creation year, such as 2003).\n # exists in this variation (creation year, such as 2003).\n
...@@ -155,6 +176,7 @@ if listbox is None:\n ...@@ -155,6 +176,7 @@ if listbox is None:\n
currency_cash_list = new_currency_cash_list\n currency_cash_list = new_currency_cash_list\n
\n \n
currency_cash_list = context.Base_sortCurrencyCashList(currency_cash_list)\n currency_cash_list = context.Base_sortCurrencyCashList(currency_cash_list)\n
context.log(\'CashDelivery_generateCashDetailInputDialog after sort\', \'currency_list = %r, operation_cur = %s\' % ([x.getTitle() for x in currency_cash_list], operation_currency))\n
\n \n
# Get the axis information based on the specified column base category.\n # Get the axis information based on the specified column base category.\n
# axis_list_dict contains the lists of objects, while axis_dict contains\n # axis_list_dict contains the lists of objects, while axis_dict contains\n
...@@ -290,6 +312,7 @@ if listbox is None:\n ...@@ -290,6 +312,7 @@ if listbox is None:\n
currency_dict[\'column%d\' % (counter + 1)] = 0\n currency_dict[\'column%d\' % (counter + 1)] = 0\n
listbox.append(currency_dict)\n listbox.append(currency_dict)\n
\n \n
context.log(\'generateFastInput, listbox\',listbox)\n
other_parameter_list = (operation_currency, line_portal_type, read_only, column_base_category, use_inventory)\n other_parameter_list = (operation_currency, line_portal_type, read_only, column_base_category, use_inventory)\n
context.Base_updateDialogForm(listbox=listbox\n context.Base_updateDialogForm(listbox=listbox\n
, calculated_price=total_price\n , calculated_price=total_price\n
...@@ -355,9 +378,13 @@ else :\n ...@@ -355,9 +378,13 @@ else :\n
for line in listbox:\n for line in listbox:\n
# must get the resource\n # must get the resource\n
resource_id = line[\'resource_id\']\n resource_id = line[\'resource_id\']\n
resource_list = context.portal_catalog(portal_type = (\'Banknote\',\'Coin\') ,id = resource_id)\n # This is a huge performance problem to call many times the catalog\n
resource_price = resource_list[0].getObject().getBasePrice()\n # for each fast input !!!!\n
line[\'resource_translated_title\'] = resource_list[0].getObject().getTranslatedTitle()\n #resource_list = context.portal_catalog(portal_type = (\'Banknote\',\'Coin\') ,id = resource_id)\n
#resource_price = resource_list[0].getObject().getBasePrice()\n
resource_value = context.currency_cash_module[resource_id]\n
resource_price = resource_value.getObject().getBasePrice()\n
line[\'resource_translated_title\'] = resource_value.getTranslatedTitle()\n
# get the number of lines to add\n # get the number of lines to add\n
if line.has_key(\'number_line_to_add\'):\n if line.has_key(\'number_line_to_add\'):\n
lines_to_add = int(line[\'number_line_to_add\'])\n lines_to_add = int(line[\'number_line_to_add\'])\n
...@@ -452,6 +479,11 @@ else :\n ...@@ -452,6 +479,11 @@ else :\n
<string>listbox</string> <string>listbox</string>
<string>cash_detail_dict</string> <string>cash_detail_dict</string>
<string>kw</string> <string>kw</string>
<string>Products.ERP5Type.Cache</string>
<string>CachingMethod</string>
<string>_getattr_</string>
<string>context</string>
<string>portal</string>
<string>None</string> <string>None</string>
<string>_getitem_</string> <string>_getitem_</string>
<string>cash_status_list</string> <string>cash_status_list</string>
...@@ -465,8 +497,6 @@ else :\n ...@@ -465,8 +497,6 @@ else :\n
<string>False</string> <string>False</string>
<string>use_inventory</string> <string>use_inventory</string>
<string>list</string> <string>list</string>
<string>_getattr_</string>
<string>context</string>
<string>generic_prioritized_sort</string> <string>generic_prioritized_sort</string>
<string>prioritized_banknote_emission_letter_list</string> <string>prioritized_banknote_emission_letter_list</string>
<string>prioritized_coin_cash_status_list</string> <string>prioritized_coin_cash_status_list</string>
...@@ -483,9 +513,10 @@ else :\n ...@@ -483,9 +513,10 @@ else :\n
<string>banknote_emission_letter_list</string> <string>banknote_emission_letter_list</string>
<string>coin_emission_letter_list</string> <string>coin_emission_letter_list</string>
<string>currency</string> <string>currency</string>
<string>result</string> <string>getCurrencyCashRelativeUrlList</string>
<string>len</string> <string>currency_cash_url_list</string>
<string>currency_cash_list</string> <string>currency_cash_list</string>
<string>len</string>
<string>new_currency_cash_list</string> <string>new_currency_cash_list</string>
<string>variation</string> <string>variation</string>
<string>currency_cash</string> <string>currency_cash</string>
...@@ -527,7 +558,7 @@ else :\n ...@@ -527,7 +558,7 @@ else :\n
<string>int</string> <string>int</string>
<string>next_listbox_key</string> <string>next_listbox_key</string>
<string>resource_id</string> <string>resource_id</string>
<string>resource_list</string> <string>resource_value</string>
<string>lines_to_add</string> <string>lines_to_add</string>
<string>xrange</string> <string>xrange</string>
<string>num</string> <string>num</string>
......
...@@ -78,6 +78,7 @@ ...@@ -78,6 +78,7 @@
<value> <value>
<list> <list>
<string>listbox</string> <string>listbox</string>
<string>listbox_destination_payment_internal_bank_account_number</string>
</list> </list>
</value> </value>
</item> </item>
......
...@@ -345,7 +345,7 @@ ...@@ -345,7 +345,7 @@
<string>Title</string> <string>Title</string>
</tuple> </tuple>
<tuple> <tuple>
<string>destination_payment_reference</string> <string>destination_payment_internal_bank_account_number</string>
<string>Account</string> <string>Account</string>
</tuple> </tuple>
<tuple> <tuple>
...@@ -402,7 +402,12 @@ ...@@ -402,7 +402,12 @@
<item> <item>
<key> <string>editable_columns</string> </key> <key> <string>editable_columns</string> </key>
<value> <value>
<list/> <list>
<tuple>
<string>destination_payment_internal_bank_account_number</string>
<string>destination_payment_internal_bank_account_number</string>
</tuple>
</list>
</value> </value>
</item> </item>
<item> <item>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="StringField" module="Products.Formulator.StandardFields"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_owner</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>listbox_destination_payment_internal_bank_account_number</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
<item>
<key> <string>required_not_found</string> </key>
<value> <string>Input is required but no input given.</string> </value>
</item>
<item>
<key> <string>too_long</string> </key>
<value> <string>Too much input was given.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>display_maxwidth</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>display_width</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>max_length</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>required</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>truncate</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>unicode</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>whitespace_preserve</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>display_maxwidth</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>display_width</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>max_length</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>required</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>truncate</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>unicode</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>whitespace_preserve</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>display_maxwidth</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>display_width</string> </key>
<value> <int>12</int> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>max_length</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>required</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Account Number</string> </value>
</item>
<item>
<key> <string>truncate</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>unicode</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>whitespace_preserve</string> </key>
<value> <int>0</int> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<tuple>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: cell.getDestinationPaymentValue().getInternalBankAccountNumber()</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -73,6 +73,10 @@ ...@@ -73,6 +73,10 @@
\n \n
from Products.ERP5Type.Document import newTempBase\n from Products.ERP5Type.Document import newTempBase\n
\n \n
if from_date is not None:\n
if from_date == at_date:\n
from_date=None\n
\n
#context.log(\'CounterModule_getVaultTransactionList vault:\',vault)\n #context.log(\'CounterModule_getVaultTransactionList vault:\',vault)\n
def getTranslatedTitleFromCategoryUrl(category):\n def getTranslatedTitleFromCategoryUrl(category):\n
return context.portal_categories.getCategoryValue(category).getTranslatedTitle()\n return context.portal_categories.getCategoryValue(category).getTranslatedTitle()\n
...@@ -346,6 +350,7 @@ return repr([x for x in total_inventory_list])\n ...@@ -346,6 +350,7 @@ return repr([x for x in total_inventory_list])\n
<string>kw</string> <string>kw</string>
<string>Products.ERP5Type.Document</string> <string>Products.ERP5Type.Document</string>
<string>newTempBase</string> <string>newTempBase</string>
<string>None</string>
<string>getTranslatedTitleFromCategoryUrl</string> <string>getTranslatedTitleFromCategoryUrl</string>
<string>getTitleFromCategoryUrl</string> <string>getTitleFromCategoryUrl</string>
<string>getVariationTitleList</string> <string>getVariationTitleList</string>
...@@ -362,7 +367,6 @@ return repr([x for x in total_inventory_list])\n ...@@ -362,7 +367,6 @@ return repr([x for x in total_inventory_list])\n
<string>_write_</string> <string>_write_</string>
<string>total_inventory_list</string> <string>total_inventory_list</string>
<string>inventory_kw</string> <string>inventory_kw</string>
<string>None</string>
<string>_getitem_</string> <string>_getitem_</string>
<string>len</string> <string>len</string>
<string>kw_has_cash_status</string> <string>kw_has_cash_status</string>
......
...@@ -97,7 +97,7 @@ from Products.ERP5Type.Cache import CachingMethod\n ...@@ -97,7 +97,7 @@ from Products.ERP5Type.Cache import CachingMethod\n
def getVaultItemList(vault_type=None, exclude_vault_type=None,\n def getVaultItemList(vault_type=None, exclude_vault_type=None,\n
user_site=1, leaf_node=1, strict_membership=0, assignment_list=None,\n user_site=1, leaf_node=1, strict_membership=0, assignment_list=None,\n
site_list=None, with_base=1, all=0, first_level=0,main_agency=0,\n site_list=None, with_base=1, all=0, first_level=0,main_agency=0,\n
exclude_site_list=None):\n exclude_site_list=None,mode_test=0):\n
\n \n
if vault_type is None:\n if vault_type is None:\n
organisation_list = []\n organisation_list = []\n
...@@ -184,11 +184,6 @@ def getVaultItemList(vault_type=None, exclude_vault_type=None,\n ...@@ -184,11 +184,6 @@ def getVaultItemList(vault_type=None, exclude_vault_type=None,\n
vault_dict = {}\n vault_dict = {}\n
# Transform each line of the vault list\n # Transform each line of the vault list\n
keep_level = []\n keep_level = []\n
erp5_site = context.getPortalObject()\n
mode_test = 0\n
if hasattr(erp5_site, \'functionnal_test_mode\'):\n
if getattr(erp5_site, \'functionnal_test_mode\') == 1:\n
mode_test = 1\n
for vault_item in vault_list:\n for vault_item in vault_list:\n
# do not include testsite if not in test mode\n # do not include testsite if not in test mode\n
if mode_test == 0 and \'testsite\' in vault_item[1]:\n if mode_test == 0 and \'testsite\' in vault_item[1]:\n
...@@ -224,6 +219,12 @@ if vault_type is None:\n ...@@ -224,6 +219,12 @@ if vault_type is None:\n
else:\n else:\n
assignment_list = None\n assignment_list = None\n
\n \n
erp5_site = context.getPortalObject()\n
mode_test = 0\n
if hasattr(erp5_site, \'functionnal_test_mode\'):\n
if getattr(erp5_site, \'functionnal_test_mode\') == 1:\n
mode_test = 1\n
\n
user_site_list = []\n user_site_list = []\n
if user_site == 1 or owner_site==1:\n if user_site == 1 or owner_site==1:\n
if owner_site:\n if owner_site:\n
...@@ -260,7 +261,8 @@ if exclude_user_site:\n ...@@ -260,7 +261,8 @@ if exclude_user_site:\n
vault_list = getVaultItemList(vault_type=vault_type, exclude_vault_type=exclude_vault_type,\n vault_list = getVaultItemList(vault_type=vault_type, exclude_vault_type=exclude_vault_type,\n
user_site=user_site, leaf_node=leaf_node, strict_membership=strict_membership,\n user_site=user_site, leaf_node=leaf_node, strict_membership=strict_membership,\n
assignment_list=assignment_list, site_list=site_list, with_base=with_base, all=all,\n assignment_list=assignment_list, site_list=site_list, with_base=with_base, all=all,\n
first_level=first_level,main_agency=main_agency,exclude_site_list=exclude_site_list)\n first_level=first_level,main_agency=main_agency,exclude_site_list=exclude_site_list,\n
mode_test=mode_test)\n
\n \n
if user_vault == 1:\n if user_vault == 1:\n
if len(user_site_list)==0:\n if len(user_site_list)==0:\n
...@@ -366,6 +368,10 @@ return [(\'\', \'\')] + list(vault_list)\n ...@@ -366,6 +368,10 @@ return [(\'\', \'\')] + list(vault_list)\n
<string>_getattr_</string> <string>_getattr_</string>
<string>context</string> <string>context</string>
<string>assignment_list</string> <string>assignment_list</string>
<string>erp5_site</string>
<string>mode_test</string>
<string>hasattr</string>
<string>getattr</string>
<string>user_site_list</string> <string>user_site_list</string>
<string>_getitem_</string> <string>_getitem_</string>
<string>new_site_list</string> <string>new_site_list</string>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Python_magic</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
from Products.ERP5Type.Document import newTempBase\n
from string import zfill\n
\n
\n
request = context.REQUEST\n
\n
# It must be possible to initialise the fast input, and to add empty lines after\n
if request.has_key(\'my_empty_line_number\'):\n
empty_line_number = request[\'my_empty_line_number\']\n
\n
\n
l = []\n
first_empty_line_id = 1\n
portal_object = context.getPortalObject()\n
int_len = 3\n
\n
def get_fast_input_discriminant(line_id):\n
line = listbox.get(line_id)\n
if line is not None:\n
resource_id = line.get(\'resource_id\')\n
if resource_id is not None:\n
cash_currency = context.currency_cash_module.get(resource_id)\n
if cash_currency is not None and cash_currency.hasBasePrice():\n
return (cash_currency.getPortalType(), -cash_currency.getBasePrice(), line_id) # First sort by base price (desc), then by line id (asc)\n
return line_id\n
\n
def sort_fast_input_lines(x, y):\n
criterion_x = get_fast_input_discriminant(x)\n
criterion_y = get_fast_input_discriminant(y)\n
if criterion_x < criterion_y:\n
return -1\n
elif criterion_x > criterion_y:\n
return 1\n
else:\n
return 0\n
\n
if hasattr(request, \'listbox\'):\n
# initialize the listbox \n
listbox=request[\'listbox\']\n
\n
keys_list = listbox.keys()\n
\n
if keys_list != []:\n
#keys_list.sort(lambda x,y: cmp(int(x),int(y)))\n
keys_list.sort(sort_fast_input_lines)\n
first_empty_line_id = int(keys_list[-1])+1\n
\n
for i in keys_list:\n
o = newTempBase(portal_object, i)\n
o.setUid(\'new_%s\' % zfill(i,int_len))\n
\n
is_empty = 1\n
\n
for key in listbox[i]:\n
value = listbox[i][key]\n
# 0 was added because of checkbox field in some fast input\n
if (value not in [\'\',None,0]) and (key != \'listbox_key\'):\n
is_empty = 0\n
if (request.has_key(\'field_errors\')):\n
is_empty = 0\n
#o.edit(key=listbox[i][key])\n
o.setProperty(key,listbox[i][key])\n
\n
if not is_empty:\n
l.append(o)\n
\n
# add empty lines\n
if not(request.has_key(\'field_errors\')):\n
for i in range(first_empty_line_id,first_empty_line_id+empty_line_number):\n
\n
o = newTempBase(portal_object, str(i))\n
o.setUid(\'new_%s\' % zfill(i,int_len)) \n
# zfill is used here to garantee sort order - XXX - cleaner approach required\n
l.append(o)\n
\n
\n
return l\n
]]></string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_filepath</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_owner</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>empty_line_number=0, **kw</string> </value>
</item>
<item>
<key> <string>errors</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>func_code</string> </key>
<value>
<object>
<klass>
<global name="FuncCode" module="Shared.DC.Scripts.Signature"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>co_argcount</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>empty_line_number</string>
<string>kw</string>
<string>Products.ERP5Type.Document</string>
<string>newTempBase</string>
<string>string</string>
<string>zfill</string>
<string>_getattr_</string>
<string>context</string>
<string>request</string>
<string>_getitem_</string>
<string>l</string>
<string>first_empty_line_id</string>
<string>portal_object</string>
<string>int_len</string>
<string>listbox</string>
<string>get_fast_input_discriminant</string>
<string>sort_fast_input_lines</string>
<string>hasattr</string>
<string>keys_list</string>
<string>int</string>
<string>_getiter_</string>
<string>i</string>
<string>o</string>
<string>is_empty</string>
<string>key</string>
<string>value</string>
<string>None</string>
<string>range</string>
<string>str</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<tuple>
<int>0</int>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ListBox_initializeFastInput</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
259 262
\ No newline at end of file \ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment