Commit 818a2e8f authored by Sebastien Robin's avatar Sebastien Robin

- added base category for check and checkbook

- the fast input of banknotes is now able to automatically fills fields for some very particular modules
- remove an unused worklist

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@15518 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 55f9ed78
......@@ -9,6 +9,7 @@
<item>variation</item>
</portal_type>
<portal_type id="Check">
<item>site</item>
<item>check_type</item>
</portal_type>
<portal_type id="Check Model Type Variation">
......@@ -19,6 +20,7 @@
</portal_type>
<portal_type id="Checkbook">
<item>resource</item>
<item>site</item>
<item>check_amount</item>
</portal_type>
<portal_type id="Checkbook Model">
......
......@@ -97,6 +97,10 @@
<key> <string>init_script</string> </key>
<value> <string>Checkbook_init</string> </value>
</item>
<item>
<key> <string>permission</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>property_sheet_list</string> </key>
<value>
......
......@@ -69,6 +69,7 @@
\n
from Products.DCWorkflow.DCWorkflow import ValidationFailed\n
from Products.ERP5Type.Message import Message\n
return\n
\n
if date is None:\n
# get current date\n
......
......@@ -67,6 +67,7 @@
<key> <string>_body</string> </key>
<value> <string>from Products.DCWorkflow.DCWorkflow import ValidationFailed\n
from Products.ERP5Type.Message import Message\n
return\n
\n
if simulation_state_list is None:\n
simulation_state_list = [\'open\']\n
......
......@@ -84,6 +84,9 @@ tmp_list = context.contentValues(filter={\'portal_type\': portal_type})\n
#context.log(\'tmp_list\', str((tmp_list, portal_type, context)))\n
#context.log(\'source\',source)\n
line_list = []\n
resource_dict = {}\n
node_dict = {}\n
variation_text_dict = {}\n
for l in tmp_list :\n
# The source can be different for every line (due to getBaobabSource approach)\n
if source is None:\n
......@@ -95,6 +98,10 @@ for l in tmp_list :\n
if (l.getResourceValue().getPortalType() in currency_cash_portal_type_list) \\\n
and (same_source or l.getBaobabSource() == source_counter) :\n
line_list.append(l)\n
resource_dict[l.getResource()] = None\n
node_dict[source_counter] = None\n
for cell in l.objectValues() :\n
variation_text_dict[cell.getVariationText()] = None\n
except (AttributeError, KeyError):\n
pass\n
#context.log("line list", line_list)\n
......@@ -114,6 +121,23 @@ def checkActivities(source_counter):\n
msg = Message(domain=\'ui\', message="There are operations pending for this vault that prevent form calculating its position. Please try again later.")\n
raise ValidationFailed, (msg,)\n
\n
inventory_list = context.portal_simulation.getCurrentInventoryList(\n
group_by_variation=1,\n
group_by_node=1,\n
group_by_resource=1,\n
node=node_dict.keys(),\n
resource=resource_dict.keys(),\n
variation_text=variation_text_dict.keys())\n
\n
inventory_dict = {}\n
inventory_key_order = [\'node\', \'resource\', \'variation_text\']\n
for inventory_line in inventory_list:\n
inventory_key = tuple([inventory_line[x] for x in inventory_key_order])\n
inventory_dict[inventory_key] = inventory_line[\'inventory\']\n
\n
def getCurrentInventory(**criterion_dict):\n
inventory_key = tuple([criterion_dict[x] for x in inventory_key_order])\n
return inventory_dict.get(inventory_key, 0)\n
\n
for line in line_list :\n
line_resource = line.getResource()\n
......@@ -139,26 +163,25 @@ for line in line_list :\n
for cell in line.objectValues() :\n
variation_text = cell.getVariationText()\n
#context.log(\'check cell : \', str((source_counter, line_resource, variation_text)))\n
inventory_value = context.portal_simulation.getCurrentInventory(node=source_counter, resource = line_resource,\n
inventory_value = getCurrentInventory(node=source_counter, resource = line_resource,\n
variation_text = variation_text)\n
#context.log(\'cell quantity\', cell.getQuantity())\n
#context.log(\'inventory value\', inventory_value)\n
if inventory_value - cell.getQuantity() < 0:\n
context.log(\'bad value for:\',context.portal_simulation.getCurrentInventory(node=source_counter, resource = line_resource,\n
variation_text = variation_text,src__=1))\n
msg = Message(domain=\'ui\', message=\'Insufficient balance for $resource, letter $letter, status $status and variation $variation\', mapping={\'resource\':cell.getResourceTranslatedTitle(),\n
\'letter\': cell.getEmissionLetterTitle(),\n
\'status\': cell.getCashStatusTranslatedTitle(),\n
\'variation\':cell.getVariationTitle()})\n
raise ValidationFailed, (msg,)\n
else :\n
inventory_value = context.portal_simulation.getCurrentInventory(section=source_counter, resource=line_resource)\n
if inventory_value - line.getQuantity() < 0 :\n
msg = Message(domain=\'ui\', message=\'Insufficient balance for $resource, letter $letter, status $status and variation $variation\', mapping={\'resource\':line.getResourceTranslatedTitle(),\n
\'letter\': line.getEmissionLetterTitle(),\n
\'status\': line.getCashStatusTranslatedTitle(),\n
\'variation\':line.getVariationTitle()})\n
raise ValidationFailed, (msg,)\n
raise ValueError, \'This script must not be used on movements without cells. It is deprecated and dangerous, therefor it raises.\'\n
# inventory_value = context.portal_simulation.getCurrentInventory(section=source_counter, resource=line_resource)\n
# if inventory_value - line.getQuantity() < 0 :\n
# msg = Message(domain=\'ui\', message=\'Insufficient balance for $resource, letter $letter, status $status and variation $variation\', mapping={\'resource\':line.getResourceTranslatedTitle(),\n
# \'letter\': line.getEmissionLetterTitle(),\n
# \'status\': line.getCashStatusTranslatedTitle(),\n
# \'variation\':line.getVariationTitle()})\n
# raise ValidationFailed, (msg,)\n
\n
return 0\n
......@@ -227,25 +250,39 @@ return 0\n
<string>context</string>
<string>tmp_list</string>
<string>line_list</string>
<string>resource_dict</string>
<string>node_dict</string>
<string>variation_text_dict</string>
<string>_getiter_</string>
<string>l</string>
<string>None</string>
<string>source_counter</string>
<string>_write_</string>
<string>cell</string>
<string>AttributeError</string>
<string>KeyError</string>
<string>len</string>
<string>serialize_dict</string>
<string>activity_tool</string>
<string>checkActivities</string>
<string>inventory_list</string>
<string>inventory_key_order</string>
<string>inventory_line</string>
<string>tuple</string>
<string>append</string>
<string>$append0</string>
<string>x</string>
<string>_getitem_</string>
<string>inventory_key</string>
<string>getCurrentInventory</string>
<string>line</string>
<string>line_resource</string>
<string>_write_</string>
<string>msg</string>
<string>source_object</string>
<string>activate_kw</string>
<string>cell</string>
<string>variation_text</string>
<string>inventory_value</string>
<string>ValueError</string>
</tuple>
</value>
</item>
......
......@@ -70,6 +70,9 @@
# listbox is not passed at the first time when this script is called.\n
# when the user clicks on the Update button, listbox is passed, and\n
# the contents must be preserved in the form.\n
#\n
# rendering_vault : the vault that we want to render, if specified we will use\n
# getInventory in order to automatically full the fast input\n
\n
from Products.ERP5Type.Cache import CachingMethod\n
portal = context.getPortalObject()\n
......@@ -163,7 +166,6 @@ if listbox is 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
\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
......@@ -176,7 +178,6 @@ 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
......@@ -218,6 +219,17 @@ if listbox is None:\n
\n
total_price = 0\n
listbox = []\n
\n
inventory_dict = {}\n
if rendering_vault is not None and len(context.objectValues(portal_type=line_portal_type))==0:\n
# build the list of ressources for this vault\n
inventory_list = context.CounterModule_getVaultTransactionList(vault=rendering_vault, at_date=context.getStartDate())\n
# build the dict of ressources for this vault, the dict\n
# allow to parse the list only one time\n
for inventory in inventory_list:\n
resource_id = inventory.resource_id\n
resource_list = inventory_dict.setdefault(resource_id, [])\n
resource_list.append(inventory)\n
\n
for currency_cash in currency_cash_list:\n
if currency_cash.getPortalType() == \'Coin\':\n
......@@ -227,11 +239,12 @@ if listbox is None:\n
cash_status_list = banknote_cash_status_list\n
emission_letter_list = banknote_emission_letter_list\n
# Search if the current object contains a line with a given portal type.\n
cash_delivery_line = context.CashDelivery_searchLineByResource(currency_cash.getId(), line_portal_type)\n
currency_cash_id = currency_cash.getId()\n
cash_delivery_line = context.CashDelivery_searchLineByResource(currency_cash_id, line_portal_type)\n
# This variable counts the number of lines added for this currency cash.\n
line_number = 0\n
\n
if cash_delivery_line is not None:\n
if cash_delivery_line is not None or len(inventory_dict.get(currency_cash_id, ()))>0:\n
# If a line exists for this cash currency, add lines into the listbox according to\n
# the currency information.\n
#context.log("cash_delivery_line", "cash_delivery_line = %s, currency = %s, type = %s" %(cash_delivery_line, currency_cash, line_portal_type))\n
......@@ -240,13 +253,21 @@ if listbox is None:\n
\n
# Collect cells according to the categories.\n
cell_dict_dict = {}\n
for cell in cash_delivery_line.getCellValueList():\n
category1 = cell.getProperty(axis_dict[\'line1\'])\n
category2 = cell.getProperty(axis_dict[\'line2\'])\n
column_category = cell.getProperty(axis_dict[\'column\'])\n
cell_list = []\n
if cash_delivery_line is not None:\n
cell_list = cash_delivery_line.getCellValueList()\n
else:\n
# the result is inside the currency_dict\n
cell_list = inventory_dict[currency_cash_id]\n
for cell in cell_list:\n
category1 = cell.getProperty(axis_dict[\'line1\']).split(\'/\')[-1]\n
category2 = cell.getProperty(axis_dict[\'line2\']).split(\'/\')[-1]\n
column_category = cell.getProperty(axis_dict[\'column\']).split(\'/\')[-1]\n
key = (category1, category2)\n
#context.log(str((key, axis_dict[\'column\'], column_category, cell.getVariation())), cell)\n
cell_dict_dict.setdefault(key, {})[column_category] = cell\n
\n
\n
\n
# Sort the keys to obtain a consistent behavior.\n
key_list = cell_dict_dict.keys()\n
......@@ -267,7 +288,7 @@ if listbox is None:\n
if use_inventory:\n
quantity = cell.getInventory()\n
else:\n
quantity = cell.getQuantity()\n
quantity = cell.getProperty(\'quantity\')\n
if not quantity:\n
continue\n
\n
......@@ -312,7 +333,6 @@ 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
......@@ -450,7 +470,7 @@ else :\n
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>listbox=None,cash_detail_dict=None, **kw</string> </value>
<value> <string>listbox=None,cash_detail_dict=None, rendering_vault=None, **kw</string> </value>
</item>
<item>
<key> <string>errors</string> </key>
......@@ -470,7 +490,7 @@ else :\n
<dictionary>
<item>
<key> <string>co_argcount</string> </key>
<value> <int>2</int> </value>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
......@@ -478,6 +498,7 @@ else :\n
<tuple>
<string>listbox</string>
<string>cash_detail_dict</string>
<string>rendering_vault</string>
<string>kw</string>
<string>Products.ERP5Type.Cache</string>
<string>CachingMethod</string>
......@@ -523,11 +544,18 @@ else :\n
<string>axis_list_dict</string>
<string>axis_dict</string>
<string>total_price</string>
<string>inventory_dict</string>
<string>inventory_list</string>
<string>inventory</string>
<string>resource_id</string>
<string>resource_list</string>
<string>currency_cash_id</string>
<string>cash_delivery_line</string>
<string>line_number</string>
<string>currency_dict</string>
<string>resource_price</string>
<string>cell_dict_dict</string>
<string>cell_list</string>
<string>cell</string>
<string>category1</string>
<string>category2</string>
......@@ -557,7 +585,6 @@ else :\n
<string>max</string>
<string>int</string>
<string>next_listbox_key</string>
<string>resource_id</string>
<string>resource_value</string>
<string>lines_to_add</string>
<string>xrange</string>
......@@ -579,6 +606,7 @@ else :\n
<tuple>
<none/>
<none/>
<none/>
</tuple>
</value>
</item>
......
......@@ -91,6 +91,7 @@ if previous_reference not in (\'\',None):\n
else:\n
reference = \'1\'\n
context.setReference(reference)\n
context.assignRoleToSecurityGroup()\n
]]></string> </value>
......
......@@ -298,6 +298,7 @@ for resource in resource_dict.keys():\n
(explanation_value.getTranslatedPortalType(),source_reference)\n
tmp_dict[\'base_price\'] = resource_value.getBasePrice()\n
tmp_dict[\'resource_title\'] = resource_value.getTitle()\n
tmp_dict[\'resource_id\'] = resource_value.getId()\n
#context.log(\'resource_value\',resource_value.getRelativeUrl())\n
try:\n
tmp_dict[\'resource_translated_title\'] = resource_value.getTranslatedTitle()\n
......@@ -321,6 +322,7 @@ for resource in resource_dict.keys():\n
total_quantity = round(total_quantity / banknote_quantity_divisor,0)\n
total_price = round(total_price / banknote_quantity_divisor,0)\n
tmp_dict.update({\'total_quantity\' : total_quantity,\n
\'quantity\': total_quantity,\n
\'total_price\' : total_price,})\n
tmp_dict.update({\'vault\' : vault})\n
if vault_report_type==\'history\':\n
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="WorklistDefinition" module="Products.DCWorkflow.Worklists"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>actbox_category</string> </key>
<value> <string>global</string> </value>
</item>
<item>
<key> <string>actbox_name</string> </key>
<value> <string>Drafts to Validate (%(count)s)</string> </value>
</item>
<item>
<key> <string>actbox_url</string> </key>
<value> <string encoding="cdata"><![CDATA[
Base_viewSearchResultList?validation_state=draft&portal_type=%(portal_type)s&reset=1
]]></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Documents to Validate</string> </value>
</item>
<item>
<key> <string>guard</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>draft</string> </value>
</item>
<item>
<key> <string>uid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>var_matches</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<tuple>
<global name="Guard" module="Products.DCWorkflow.Guard"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>roles</string> </key>
<value>
<tuple>
<string>Manager</string>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<tuple>
<global name="PersistentMapping" module="Persistence.mapping"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>validation_state</string> </key>
<value>
<tuple>
<string>draft</string>
</tuple>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -48,17 +48,14 @@
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<tuple>
<tuple>
<string>Persistence</string>
<string>PersistentMapping</string>
</tuple>
<none/>
<global name="PersistentMapping" module="Persistence.mapping"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_container</string> </key>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
......@@ -67,6 +64,7 @@
<tuple>
<string>Assignor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
......@@ -76,6 +74,7 @@
<tuple>
<string>Assignor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
......@@ -85,6 +84,7 @@
<tuple>
<string>Assignor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
......
330
\ No newline at end of file
335
\ No newline at end of file
......@@ -4,7 +4,9 @@ Cash Delivery Cell | variation
Check Model Type Variation | check_type
Check Operation Line | aggregate_resource
Check | check_type
Check | site
Checkbook Model | composition
Checkbook | check_amount
Checkbook | resource
Checkbook | site
Counter Date | site
\ 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