Commit 4710da5a authored by Sebastien Robin's avatar Sebastien Robin

2009-01-19 Seb

Theses scripts will move to erp5_administration business template and will be reviewed.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@25181 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent b6da6119
<?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>Script_magic</string> </key>
<value> <int>3</int> </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>active_process = context.newActiveProcess()\n
result = context.Alarm_checkStockTable(active_process=\'/\'.join(active_process.getPhysicalPath()))\n
active_process.postResult(result)\n
</string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></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>0</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>_getattr_</string>
<string>context</string>
<string>active_process</string>
<string>result</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Alarm_activateCheckStockTable</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?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>Script_magic</string> </key>
<value> <int>3</int> </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>return context.ERP5Site_checkStockTable(bundle_object_count=bundle_object_count,\n
bundle_offset=bundle_offset,\n
property_override_method_id=\'ERP5Site_getStockTableFilterDict\',\n
active_process=active_process)\n
</string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>bundle_object_count=100, bundle_offset=0, active_process=None</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>3</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>bundle_object_count</string>
<string>bundle_offset</string>
<string>active_process</string>
<string>_getattr_</string>
<string>context</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<tuple>
<int>100</int>
<int>0</int>
<none/>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Alarm_checkStockTable</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="SQL" module="Products.ZSQLMethods.SQL"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_arg</string> </key>
<value>
<object>
<klass>
<global name="Args" module="Shared.DC.ZRDB.Aqueduct"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_data</string> </key>
<value>
<dictionary>
<item>
<key> <string>limit</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>_keys</string> </key>
<value>
<list>
<string>limit</string>
</list>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>allow_simple_one_argument_traversal</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>arguments_src</string> </key>
<value> <string>limit</string> </value>
</item>
<item>
<key> <string>cache_time_</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>class_file_</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>class_name_</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>connection_hook</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>connection_id</string> </key>
<value> <string>erp5_sql_connection</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_zGetAllFromStock</string> </value>
</item>
<item>
<key> <string>max_cache_</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>max_rows_</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>src</string> </key>
<value> <string encoding="cdata"><![CDATA[
select * from stock\n
LIMIT <dtml-var expr="limit[0]">, <dtml-var expr="limit[1]">
]]></string> </value>
</item>
<item>
<key> <string>template</string> </key>
<value>
<object>
<klass>
<global name="__newobj__" module="copy_reg"/>
</klass>
<tuple>
<global name="SQL" module="Shared.DC.ZRDB.DA"/>
</tuple>
<state>
<dictionary>
<item>
<key> <string>__name__</string> </key>
<value> <string encoding="cdata"><![CDATA[
<string>
]]></string> </value>
</item>
<item>
<key> <string>_vars</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>globals</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>raw</string> </key>
<value> <string encoding="cdata"><![CDATA[
select * from stock\n
LIMIT <dtml-var expr="limit[0]">, <dtml-var expr="limit[1]">
]]></string> </value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?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>Script_magic</string> </key>
<value> <int>3</int> </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[
"""\n
Check that catalog tables contain data which is coherent with actual objects.\n
Due to the number of objects to check, this function creates activites working\n
on, at maximum, bundle_object_count objects.\n
\n
bundle_object_count\n
Maximum number of objects to deal with in one transaction. \n
An activity is started after each successfull execution which\n
found bundle_object_count to work on.\n
bundle_offset\n
Offset the bundle, to allow walking along the catalog with\n
bundle_object_count increment.\n
property_override_method_id\n
Id of a method generating a property_override_dict as described below and\n
returning it.\n
property_override_dict (key: catalog column id, value: method id)\n
Defines custom methods to calculate reference column value.\n
None means that the column is not checked at all.\n
Otherwise, the function will be called on the object with no parameter\n
and must return the reference value for the column.\n
"""\n
MARKER = tuple()\n
bundle_object_count=int(bundle_object_count)\n
bundle_offset=int(bundle_offset)\n
null_value_list = (\'\', None, 0.0, 0) # Values which are all considered equal.\n
portal_catalog = context.getPortalObject().portal_catalog\n
\n
if property_override_method_id is None:\n
property_override_dict = {}\n
else:\n
property_override_dict = getattr(context, property_override_method_id)()\n
\n
if active_process is not None:\n
from Products.CMFActivity.ActiveResult import ActiveResult\n
result_list = []\n
\n
stock_line_list = context.Base_zGetAllFromStock(limit=(bundle_offset, bundle_object_count))\n
attribute_id_list = stock_line_list.names()\n
for stock_line in stock_line_list:\n
object_candidate_list = portal_catalog(uid=stock_line[\'uid\'])\n
if len(object_candidate_list) != 1:\n
raise Exception, \'There are %s object catalogged with uid %s, 1 was expected.\' % (len(object_candidate_list), repr(stock_line[\'uid\']))\n
actual_object = object_candidate_list[0].getObject()\n
if actual_object.getPortalType().endswith(\' Inventory\'):\n
continue\n
for attribute_id in attribute_id_list:\n
override_method_id = property_override_dict.get(attribute_id, MARKER)\n
if override_method_id is None:\n
continue\n
elif override_method_id is MARKER:\n
reference_value = actual_object.getProperty(key=attribute_id)\n
elif same_type(override_method_id, \'\'):\n
reference_value = getattr(actual_object, override_method_id)()\n
else:\n
reference_value = override_method_id(instance=actual_object)\n
catalog_value = stock_line[attribute_id]\n
reference_can_be_null_value = False\n
if same_type(reference_value, tuple()) or same_type(reference_value, list()):\n
for reference_value_item in reference_value:\n
if reference_value_item in null_value_list:\n
reference_can_be_null_value = True\n
break\n
else:\n
if reference_value in null_value_list:\n
reference_can_be_null_value = True\n
if reference_can_be_null_value and catalog_value in null_value_list:\n
continue\n
elif same_type(reference_value, ()):\n
if catalog_value not in reference_value:\n
message = \'%s.%s has candidate list %s, but catalog contains %s\' % (actual_object.getRelativeUrl(), attribute_id, repr(reference_value), repr(catalog_value))\n
if active_process is None:\n
print \'%s<br/>\' % (message, )\n
else:\n
result_list.append(message)\n
elif reference_value != catalog_value:\n
message = \'%s.%s = %s, but catalog contains %s\' % (actual_object.getRelativeUrl(), attribute_id, repr(reference_value), repr(catalog_value))\n
if active_process is None:\n
print \'%s<br/>\' % (message, )\n
else:\n
result_list.append(message)\n
\n
if len(stock_line_list) == bundle_object_count:\n
if active_process is None:\n
print \'<a href="%s?bundle_object_count=%s&amp;bundle_offset:int=%s&amp;property_override_method_id=%s">Next</a>\' % (context.REQUEST[\'URL\'], bundle_object_count, bundle_offset + bundle_object_count, property_override_method_id)\n
else:\n
context.getPortalObject().person_module.activate(active_process=active_process).ERP5Site_checkStockTable(bundle_object_count=bundle_object_count, bundle_offset=bundle_offset + bundle_object_count, property_override_method_id=property_override_method_id, active_process=active_process)\n
\n
if active_process is None:\n
return printed\n
else:\n
active_result = ActiveResult()\n
summary_list = []\n
summary_list.append(\'Entries %s..%s\' % (bundle_offset, bundle_offset + len(stock_line_list)))\n
severity = len(result_list)\n
if severity == 0:\n
summary_list.append(\'Success\')\n
else:\n
summary_list.append(\'Failed\')\n
active_result.edit(summary=\', \'.join(summary_list), severity=severity, detail=\'\\n\'.join(result_list))\n
return active_result\n
]]></string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>bundle_object_count=100, bundle_offset=0, property_override_method_id=None, active_process=None</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>4</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>bundle_object_count</string>
<string>bundle_offset</string>
<string>property_override_method_id</string>
<string>active_process</string>
<string>_print_</string>
<string>_print</string>
<string>tuple</string>
<string>MARKER</string>
<string>int</string>
<string>None</string>
<string>null_value_list</string>
<string>_getattr_</string>
<string>context</string>
<string>portal_catalog</string>
<string>property_override_dict</string>
<string>getattr</string>
<string>Products.CMFActivity.ActiveResult</string>
<string>ActiveResult</string>
<string>result_list</string>
<string>stock_line_list</string>
<string>attribute_id_list</string>
<string>_getiter_</string>
<string>stock_line</string>
<string>_getitem_</string>
<string>object_candidate_list</string>
<string>len</string>
<string>Exception</string>
<string>repr</string>
<string>actual_object</string>
<string>attribute_id</string>
<string>override_method_id</string>
<string>reference_value</string>
<string>same_type</string>
<string>catalog_value</string>
<string>False</string>
<string>reference_can_be_null_value</string>
<string>list</string>
<string>reference_value_item</string>
<string>True</string>
<string>message</string>
<string>active_result</string>
<string>summary_list</string>
<string>severity</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<tuple>
<int>100</int>
<int>0</int>
<none/>
<none/>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ERP5Site_checkStockTable</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?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>Script_magic</string> </key>
<value> <int>3</int> </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>from DateTime import DateTime\n
\n
def getSourceAndDestinationList(instance):\n
return (instance.getSourceUid(), instance.getDestinationUid())\n
\n
def getSourcePaymentAndDestinationPaymentList(instance):\n
return (instance.getSourcePaymentUid(), instance.getDestinationPaymentUid())\n
\n
def getSimulationState(instance):\n
return instance.getSimulationState()\n
\n
def stripDate(date):\n
"""\n
Strip everything from the given DateTime parameter,\n
leaving just year, month and day.\n
"""\n
if not same_type(date, DateTime()):\n
return date\n
return DateTime(date.Date())\n
\n
def getStartDateAndStopDate(instance):\n
start_date = stripDate(instance.getStartDate())\n
stop_date = stripDate(instance.getStopDate())\n
return (start_date, stop_date)\n
\n
def getSourceSectionAndDestinationSectionList(instance):\n
return (instance.getSourceSectionUid(), instance.getDestinationSectionUid())\n
\n
def getTotalPrice(instance):\n
price = instance.getTotalPrice()\n
if price is None:\n
return None\n
return (instance.getDestinationInventoriatedTotalAssetPrice(), instance.getSourceInventoriatedTotalAssetPrice())\n
\n
def getQuantity(instance):\n
quantity = instance.getInventoriatedQuantity()\n
if quantity is None:\n
return None\n
return (quantity, -quantity)\n
\n
return {\n
\'node_uid\': getSourceAndDestinationList,\n
\'payment_uid\': getSourcePaymentAndDestinationPaymentList,\n
\'section_uid\': getSourceSectionAndDestinationSectionList,\n
\'mirror_section_uid\': getSourceSectionAndDestinationSectionList,\n
\'date\': getStartDateAndStopDate,\n
\'mirror_date\': getStartDateAndStopDate,\n
\'total_price\': getTotalPrice,\n
\'quantity\': getQuantity,\n
\'mirror_node_uid\': getSourceAndDestinationList,\n
\'simulation_state\': getSimulationState,\n
}\n
</string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></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>0</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>DateTime</string>
<string>getSourceAndDestinationList</string>
<string>getSourcePaymentAndDestinationPaymentList</string>
<string>getSimulationState</string>
<string>stripDate</string>
<string>getStartDateAndStopDate</string>
<string>getSourceSectionAndDestinationSectionList</string>
<string>getTotalPrice</string>
<string>getQuantity</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ERP5Site_getStockTableFilterDict</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
1068
\ No newline at end of file
1073
\ 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