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
user_site=0,base_site=site.getRelativeUrl(),all=1,\n
vault_type=(\'site/surface/banque_interne\',\'site/surface/gros_paiement\',\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
counter_vault_url = counter_vault[1]\n
if counter_vault_url==\'\':\n
......
......@@ -79,13 +79,13 @@
a = a_source.getResourceValue()\n
b = b_source.getResourceValue()\n
\n
# First, compare the base prices (such as 1000 and 2000 Francs CFA).\n
result = - cmp(a.getBasePrice(), b.getBasePrice())\n
# Second, compare the portal types.\n
result = cmp(a.getPortalType(), b.getPortalType())\n
if result != 0:\n
return result\n
\n
# Second, compare the portal types.\n
result = cmp(a.getPortalType(), b.getPortalType())\n
# First, compare the base prices (such as 1000 and 2000 Francs CFA).\n
result = - cmp(a.getBasePrice(), b.getBasePrice())\n
if result != 0:\n
return result\n
\n
......
......@@ -71,6 +71,9 @@
# when the user clicks on the Update button, listbox is passed, and\n
# the contents must be preserved in the form.\n
\n
from Products.ERP5Type.Cache import CachingMethod\n
portal = context.getPortalObject()\n
\n
if listbox is None:\n
# This is the first time.\n
cash_status_list = cash_detail_dict[\'cash_status_list\']\n
......@@ -140,9 +143,27 @@ if listbox is None:\n
\n
# Get the currency cash objects for a given 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
currency_cash_list = [x.getObject() for x in result if x.getObject().getPriceCurrency() == currency and len(x.getObject().getVariationList())>0]\n
#context.log(\'CashDelivery_generateCashDetailInputDialog\', \'currency_list = %r, operation_cur = %s\' % (currency_cash_list, operation_currency))\n
currency_cash_list = [x.getObject() for x in result \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
# 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
......@@ -155,6 +176,7 @@ if listbox is None:\n
currency_cash_list = new_currency_cash_list\n
\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
# 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
......@@ -290,6 +312,7 @@ if listbox is None:\n
currency_dict[\'column%d\' % (counter + 1)] = 0\n
listbox.append(currency_dict)\n
\n
context.log(\'generateFastInput, listbox\',listbox)\n
other_parameter_list = (operation_currency, line_portal_type, read_only, column_base_category, use_inventory)\n
context.Base_updateDialogForm(listbox=listbox\n
, calculated_price=total_price\n
......@@ -355,9 +378,13 @@ else :\n
for line in listbox:\n
# must get the resource\n
resource_id = line[\'resource_id\']\n
resource_list = context.portal_catalog(portal_type = (\'Banknote\',\'Coin\') ,id = resource_id)\n
resource_price = resource_list[0].getObject().getBasePrice()\n
line[\'resource_translated_title\'] = resource_list[0].getObject().getTranslatedTitle()\n
# This is a huge performance problem to call many times the catalog\n
# for each fast input !!!!\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
if line.has_key(\'number_line_to_add\'):\n
lines_to_add = int(line[\'number_line_to_add\'])\n
......@@ -452,6 +479,11 @@ else :\n
<string>listbox</string>
<string>cash_detail_dict</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>_getitem_</string>
<string>cash_status_list</string>
......@@ -465,8 +497,6 @@ else :\n
<string>False</string>
<string>use_inventory</string>
<string>list</string>
<string>_getattr_</string>
<string>context</string>
<string>generic_prioritized_sort</string>
<string>prioritized_banknote_emission_letter_list</string>
<string>prioritized_coin_cash_status_list</string>
......@@ -483,9 +513,10 @@ else :\n
<string>banknote_emission_letter_list</string>
<string>coin_emission_letter_list</string>
<string>currency</string>
<string>result</string>
<string>len</string>
<string>getCurrencyCashRelativeUrlList</string>
<string>currency_cash_url_list</string>
<string>currency_cash_list</string>
<string>len</string>
<string>new_currency_cash_list</string>
<string>variation</string>
<string>currency_cash</string>
......@@ -527,7 +558,7 @@ else :\n
<string>int</string>
<string>next_listbox_key</string>
<string>resource_id</string>
<string>resource_list</string>
<string>resource_value</string>
<string>lines_to_add</string>
<string>xrange</string>
<string>num</string>
......
......@@ -78,6 +78,7 @@
<value>
<list>
<string>listbox</string>
<string>listbox_destination_payment_internal_bank_account_number</string>
</list>
</value>
</item>
......
......@@ -345,7 +345,7 @@
<string>Title</string>
</tuple>
<tuple>
<string>destination_payment_reference</string>
<string>destination_payment_internal_bank_account_number</string>
<string>Account</string>
</tuple>
<tuple>
......@@ -402,7 +402,12 @@
<item>
<key> <string>editable_columns</string> </key>
<value>
<list/>
<list>
<tuple>
<string>destination_payment_internal_bank_account_number</string>
<string>destination_payment_internal_bank_account_number</string>
</tuple>
</list>
</value>
</item>
<item>
......
......@@ -73,6 +73,10 @@
\n
from Products.ERP5Type.Document import newTempBase\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
def getTranslatedTitleFromCategoryUrl(category):\n
return context.portal_categories.getCategoryValue(category).getTranslatedTitle()\n
......@@ -346,6 +350,7 @@ return repr([x for x in total_inventory_list])\n
<string>kw</string>
<string>Products.ERP5Type.Document</string>
<string>newTempBase</string>
<string>None</string>
<string>getTranslatedTitleFromCategoryUrl</string>
<string>getTitleFromCategoryUrl</string>
<string>getVariationTitleList</string>
......@@ -362,7 +367,6 @@ return repr([x for x in total_inventory_list])\n
<string>_write_</string>
<string>total_inventory_list</string>
<string>inventory_kw</string>
<string>None</string>
<string>_getitem_</string>
<string>len</string>
<string>kw_has_cash_status</string>
......
......@@ -97,7 +97,7 @@ from Products.ERP5Type.Cache import CachingMethod\n
def getVaultItemList(vault_type=None, exclude_vault_type=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
exclude_site_list=None):\n
exclude_site_list=None,mode_test=0):\n
\n
if vault_type is None:\n
organisation_list = []\n
......@@ -184,11 +184,6 @@ def getVaultItemList(vault_type=None, exclude_vault_type=None,\n
vault_dict = {}\n
# Transform each line of the vault list\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
# do not include testsite if not in test mode\n
if mode_test == 0 and \'testsite\' in vault_item[1]:\n
......@@ -224,6 +219,12 @@ if vault_type is None:\n
else:\n
assignment_list = None\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
if user_site == 1 or owner_site==1:\n
if owner_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
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
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
if user_vault == 1:\n
if len(user_site_list)==0:\n
......@@ -366,6 +368,10 @@ return [(\'\', \'\')] + list(vault_list)\n
<string>_getattr_</string>
<string>context</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>_getitem_</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
\ No newline at end of file
262
\ 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