Commit 51b0f0f7 authored by Sebastien Robin's avatar Sebastien Robin

many small modification in order to improve performance and fix bugs

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@9564 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 9ef4cf59
......@@ -98,7 +98,7 @@
</item>
<item>
<key> <string>init_script</string> </key>
<value> <string></string> </value>
<value> <string>CheckModel_init</string> </value>
</item>
<item>
<key> <string>property_sheet_list</string> </key>
......
......@@ -98,7 +98,7 @@
</item>
<item>
<key> <string>init_script</string> </key>
<value> <string></string> </value>
<value> <string>CheckbookModel_init</string> </value>
</item>
<item>
<key> <string>property_sheet_list</string> </key>
......
......@@ -36,6 +36,12 @@
<none/>
</value>
</item>
<item>
<key> <string>_property_domain_dict</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>_roles</string> </key>
<value>
......
......@@ -81,8 +81,10 @@ except AttributeError:\n
# if it\'s not defined, try to generate it\n
if reference in (None, \'\') or not str(reference).startswith(application_id):\n
# codification\n
source = context.getSourceValue()\n
if source not in (None, \'\'):\n
source_url = context.getSource()\n
# Make sure we do not get the codification of a counter\n
if source_url not in (None, \'\'):\n
source = context.Baobab_getVaultSite(source_url)\n
codification = source.getCodification()\n
if codification in (None, \'\'):\n
return \'\'\n
......@@ -173,6 +175,7 @@ return reference\n
<string>AttributeError</string>
<string>None</string>
<string>str</string>
<string>source_url</string>
<string>source</string>
<string>codification</string>
<string>site_list</string>
......
......@@ -68,39 +68,8 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
rate_list = context.CurrencyExchange_getExchangeRateList()\n
rate = None\n
if len(rate_list) > 0:\n
rate = rate_list[1]\n
if rate is None:\n
return None\n
\n
base_price = context.getSourceTotalAssetPrice()\n
if base_price is None:\n
return None\n
\n
price = rate * base_price\n
\n
commission_ratio = context.getDiscountRatio()\n
commission_price = context.getDiscount()\n
if commission_ratio is not None and commission_ratio !=0 and commission_price is not None and commission_price !=0:\n
return None\n
# Do not return if commission_ratio and comission_price is 0 or Null, sometimes we have no commission\n
\n
if commission_ratio is not None:\n
commission_value = commission_ratio * price\n
\n
if commission_price is not None:\n
commission_value = commission_price\n
\n
quantity = price - commission_value\n
context.setQuantity(quantity)\n
return quantity\n
]]></string> </value>
<value> <string>return context.CurrencyPurchase_getQuantity(**kw)\n
</string> </value>
</item>
<item>
<key> <string>_code</string> </key>
......@@ -120,7 +89,7 @@ return quantity\n
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
<value> <string>**kw</string> </value>
</item>
<item>
<key> <string>errors</string> </key>
......@@ -146,19 +115,10 @@ return quantity\n
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>kw</string>
<string>_apply_</string>
<string>_getattr_</string>
<string>context</string>
<string>rate_list</string>
<string>None</string>
<string>rate</string>
<string>len</string>
<string>_getitem_</string>
<string>base_price</string>
<string>price</string>
<string>commission_ratio</string>
<string>commission_price</string>
<string>commission_value</string>
<string>quantity</string>
</tuple>
</value>
</item>
......
......@@ -352,8 +352,8 @@
<string>Title</string>
</tuple>
<tuple>
<string>default_destination_section_title</string>
<string>Holder</string>
<string>destination_payment_reference</string>
<string>Account</string>
</tuple>
<tuple>
<string>resource_title</string>
......
......@@ -82,7 +82,7 @@ if start_number == None and stop_number == None:\n
stop_number = int(request[\'field_my_stop_number\'])\n
\n
context.setTitle(\'%s - %s\' % (start_number, stop_number))\n
for i in range(start_number, stop_number + 1):\n
for i in range(int(start_number), int(stop_number) + 1):\n
newline = context.newContent(portal_type=\'Check\', title=str(i))\n
newline.setDestination(context.getDestinationSection())\n
newline.setStartDate(context.getStartDate())\n
......@@ -96,6 +96,12 @@ request.RESPONSE.redirect(context.absolute_url())\n
<none/>
</value>
</item>
<item>
<key> <string>_dav_writelocks</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_filepath</string> </key>
<value> <string>Script (Python):/baobab/portal_skins/erp5_banking_core/Checkbook_createCheckList</string> </value>
......@@ -177,4 +183,25 @@ request.RESPONSE.redirect(context.absolute_url())\n
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<tuple>
<tuple>
<string>Persistence</string>
<string>PersistentMapping</string>
</tuple>
<none/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_container</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -340,7 +340,7 @@
<string>ID</string>
</tuple>
<tuple>
<string>reference</string>
<string>title</string>
<string>Check Number</string>
</tuple>
<tuple>
......
......@@ -97,7 +97,7 @@ vault_dict[vault_url] = 1\n
\n
vault_inventory_dict[vault_url] = {}\n
inventory_kw = {}\n
context.log(\'CounterModule_getVaultTransactionList, vault_report_type\',vault_report_type)\n
#context.log(\'CounterModule_getVaultTransactionList, vault_report_type\',vault_report_type)\n
if vault_report_type is None or vault_report_type==\'inventory\':\n
inventory_kw[\'group_by_variation\'] = 1\n
inventory_kw[\'group_by_resource\'] = 1\n
......@@ -130,14 +130,16 @@ if column_names == 1:\n
column_list.append((\'general_total_price\', \'General TotalPrice\'))\n
return column_list\n
\n
context.log(\'node_category\',vault)\n
context.log(\'inventory_kw\',inventory_kw)\n
vault_inventory_list = context.portal_simulation.getCurrentInventoryList( node_category=vault\n
, ignore_variation=0\n
,**inventory_kw\n
)\n
context.log(\'CounterMOdule_getVaultTransactionList, sql src:\',context.portal_simulation.getCurrentInventoryList( node_category=vault\n
, ignore_variation=0,src__=1\n
,**inventory_kw\n
))\n
# context.log(\'CounterMOdule_getVaultTransactionList, sql src:\',context.portal_simulation.getCurrentInventoryList( node_category=vault\n
# , ignore_variation=0,src__=1\n
# ,**inventory_kw\n
# ))\n
\n
#context.log(\'len(vault_inventory_list:\',len(vault_inventory_list))\n
for vault_inventory in vault_inventory_list:\n
......@@ -153,6 +155,8 @@ for vault_inventory in vault_inventory_list:\n
total_price = vault_inventory.total_price\n
if total_price is None:\n
total_price = 0\n
# context.log(\'type\',type(total_price))\n
# context.log(\'sql total_price\',total_price)\n
vault_inventory_dict[vault_url][resource] = {\'quantity\':total_quantity, \'total_price\':total_price,\n
\'date\':vault_inventory.date}\n
\n
......@@ -187,14 +191,14 @@ for resource in resource_dict.keys():\n
continue\n
if len(resource)==3:\n
movement = context.portal_catalog.getObject(resource[2])\n
context.log(\'movement\',movement)\n
#context.log(\'movement\',movement)\n
explanation_value = movement\n
if getattr(movement,\'getExplanationValue\',None) is not None:\n
explanation_value = movement.getExplanationValue()\n
tmp_dict[\'explanation_relative_url\'] = explanation_value.getRelativeUrl()\n
tmp_dict[\'base_price\'] = resource_value.getBasePrice()\n
tmp_dict[\'resource_title\'] = resource_value.getTitle()\n
context.log(\'resource_value\',resource_value.getRelativeUrl())\n
#context.log(\'resource_value\',resource_value.getRelativeUrl())\n
try:\n
tmp_dict[\'resource_translated_title\'] = resource_value.getTranslatedTitle()\n
except KeyError:\n
......@@ -212,6 +216,8 @@ for resource in resource_dict.keys():\n
\'total_price\' : resource_in_vault[\'total_price\'],\n
\'date\':resource_in_vault[\'date\']})\n
general_total_price += resource_in_vault[\'total_price\']\n
#context.log(\'total_quantity\',tmp_dict[\'total_quantity\'])\n
#context.log(\'total_price\',tmp_dict[\'total_price\'])\n
tmp_dict[\'general_total_price\'] = general_total_price\n
total_inventory_list.append(newTempBase(context, "new_%3i" % i, **tmp_dict))\n
i += 1\n
......@@ -295,12 +301,12 @@ return repr([x for x in total_inventory_list])\n
<string>vault_url</string>
<string>_write_</string>
<string>inventory_kw</string>
<string>_getattr_</string>
<string>context</string>
<string>None</string>
<string>_getattr_</string>
<string>_getitem_</string>
<string>column_list</string>
<string>_getiter_</string>
<string>context</string>
<string>_apply_</string>
<string>vault_inventory_list</string>
<string>vault_inventory</string>
......
......@@ -86,7 +86,9 @@ if commission_price is not None:\n
commission_value = commission_price\n
\n
quantity = price - commission_value\n
context.setQuantity(quantity)\n
quantity = round(quantity-0.5,0)\n
if quantity!=context.getQuantity():\n
context.setQuantity(quantity)\n
return quantity\n
</string> </value>
</item>
......@@ -148,6 +150,7 @@ return quantity\n
<string>None</string>
<string>commission_value</string>
<string>quantity</string>
<string>round</string>
</tuple>
</value>
</item>
......
......@@ -86,7 +86,9 @@ if commission_price is not None:\n
commission_value = commission_price\n
\n
quantity = price + commission_value\n
context.setQuantity(quantity)\n
quantity = round(quantity+0.5,0)\n
if quantity!=context.getQuantity():\n
context.setQuantity(quantity)\n
return quantity\n
</string> </value>
</item>
......@@ -148,6 +150,7 @@ return quantity\n
<string>None</string>
<string>commission_value</string>
<string>quantity</string>
<string>round</string>
</tuple>
</value>
</item>
......
......@@ -89,8 +89,11 @@
# utilis\xc3\xa9 en m\xc3\xaame temps que leaf_node\n
# with_base = 1 : D\xc3\xa9finie si on renvoie la base categorie \'site\' dans la liste de valeur\n
# all = 0 : Affiche aussi entrante/sortante, utile pour les inventaires\n
# first_level = 0 : Ne prend que le premier niveau pour un vault type, meme si les sous categories\n
# ont le meme vault_type\n
\n
from Products.ERP5Type.Cache import CachingMethod\n
from DateTime import DateTime\n
\n
def calculateNewTitle(title_path_list,path_len=0):\n
if \'Encaisse\' in title_path_list[-1]:\n
......@@ -125,7 +128,7 @@ def calculateNewTitle(title_path_list,path_len=0):\n
new_title_list.append(\'Ventilation\')\n
elif \'Transit\' in title_path_list[i]:\n
new_title_list.append(\'Transit\')\n
if id not in new_title_list: # ie last part of path\n
if id not in new_title_list and not id.startswith(\'Guichet\'): # ie last part of path\n
new_title_list.append(id)\n
# put back the counter name into the list\n
if counter_name is not None:\n
......@@ -133,7 +136,8 @@ def calculateNewTitle(title_path_list,path_len=0):\n
return new_title_list\n
\n
def getVaultItemList(vault_type=None, exclude_vault_type=None,\n
user_site=1, leaf_node=1, strict_membership=0, assignment_list=None, site_list=None, with_base=1, all=0):\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):\n
\n
if vault_type is None:\n
organisation_list = []\n
......@@ -175,22 +179,38 @@ def getVaultItemList(vault_type=None, exclude_vault_type=None,\n
vault_dict = {}\n
is_member_of = context.portal_categories.isMemberOf\n
get_cat_value = context.portal_categories.getCategoryValue\n
end = DateTime()\n
for site in site_list:\n
site_object = get_cat_value(site, base_category=\'site\')\n
site_member_list = site_object.getCategoryChildLogicalPathItemList(base=1)[1:]\n
\n
vault_type_value_list = [context.portal_categories.restrictedTraverse(\'vault_type/%s\' % x) for x in vault_type]\n
vault_type_uid_list = [x.getUid() for x in vault_type_value_list]\n
catalog_kw = {}\n
if strict_membership:\n
catalog_kw[\'strict_vault_type_uid\']=vault_type_uid_list\n
else:\n
catalog_kw[\'vault_type_uid\']=vault_type_uid_list\n
site_member_list = context.portal_catalog(portal_type=\'Category\',\n
relative_url=\'%s%%\' % site_object.getRelativeUrl(),\n
**catalog_kw\n
)\n
for site_member in site_member_list:\n
site_member_object = get_cat_value(site_member[1])\n
for vault_type_item in vault_type:\n
if is_member_of(site_member_object, vault_type_item, strict=strict_membership):\n
site_member_object = site_member.getObject()\n
site_member_relative_url = site_member_object.getRelativeUrl()\n
for exclude_vault_type_item in exclude_vault_type:\n
if is_member_of(site_member_object, exclude_vault_type_item, strict=0) :\n
break\n
else:\n
if leaf_node == 1:\n
if len(site_member_object.contentValues()) == 0:\n
vault_dict[site_member[1]] = site_member\n
if first_level == 1 and site_member_object.getParentValue().getVaultType()==site_member_object.getVaultType():\n
pass\n
elif leaf_node == 1:\n
if len(site_member_object) == 0:\n
site_member_logical_path = site_member_object.getLogicalPath()\n
vault_dict[site_member_relative_url] = [site_member_logical_path,site_member_relative_url]\n
else:\n
vault_dict[site_member[1]] = site_member\n
site_member_logical_path = site_member_object.getLogicalPath()\n
vault_dict[site_member_relative_url] = [site_member_logical_path,site_member_relative_url]\n
\n
\n
vault_list = vault_dict.values()\n
\n
......@@ -252,7 +272,8 @@ else:\n
\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
assignment_list=assignment_list, site_list=site_list, with_base=with_base, all=all,\n
first_level=first_level)\n
\n
if current_url != None :\n
if \'site\' not in current_url:\n
......@@ -295,7 +316,7 @@ return [(\'\', \'\')] + list(vault_list)\n
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>vault_type=None, exclude_vault_type=None, current_url=None, user_site=1, leaf_node=1, strict_membership=0, with_base=1, all=0, base_site=None, owner_site=0</string> </value>
<value> <string>vault_type=None, exclude_vault_type=None, current_url=None, user_site=1, leaf_node=1, strict_membership=0, with_base=1, all=0, base_site=None, owner_site=0,first_level=0</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
......@@ -323,7 +344,7 @@ return [(\'\', \'\')] + list(vault_list)\n
<dictionary>
<item>
<key> <string>co_argcount</string> </key>
<value> <int>10</int> </value>
<value> <int>11</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
......@@ -339,8 +360,10 @@ return [(\'\', \'\')] + list(vault_list)\n
<string>all</string>
<string>base_site</string>
<string>owner_site</string>
<string>first_level</string>
<string>Products.ERP5Type.Cache</string>
<string>CachingMethod</string>
<string>DateTime</string>
<string>calculateNewTitle</string>
<string>None</string>
<string>getVaultItemList</string>
......@@ -383,6 +406,7 @@ return [(\'\', \'\')] + list(vault_list)\n
<int>0</int>
<none/>
<int>0</int>
<int>0</int>
</tuple>
</value>
</item>
......
......@@ -73,7 +73,7 @@
rate_list = context.CurrencyExchange_getExchangeRateList()\n
rate = None\n
if len(rate_list) > 0:\n
rate = rate_list[1]\n
rate = rate_list[0]\n
\n
price = context.getSourceTotalAssetPrice()\n
\n
......
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