Commit 52a62a7d authored by Nicolas Dumazet's avatar Nicolas Dumazet

unit definitions: add validation workflow (1/2)

* Add validation workflow to Quantity Unit Conversion Definition & Group
* Only validated objects can define a valid quantity unit
* Add interaction workflow event: when an object is (in)validated,
  invalidate the Cache for site-wide quantities

* Fix b/c test by using proper tear down methods in other tests and by clearing
  the cache


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@32195 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent e3d7a996
...@@ -29,11 +29,11 @@ ...@@ -29,11 +29,11 @@
</chain> </chain>
<chain> <chain>
<type>Quantity Unit Conversion Definition</type> <type>Quantity Unit Conversion Definition</type>
<workflow>edit_workflow, quantity_unit_conversion_interaction_workflow</workflow> <workflow>edit_workflow, quantity_unit_conversion_interaction_workflow, validation_workflow</workflow>
</chain> </chain>
<chain> <chain>
<type>Quantity Unit Conversion Group</type> <type>Quantity Unit Conversion Group</type>
<workflow>edit_workflow, quantity_unit_conversion_interaction_workflow</workflow> <workflow>edit_workflow, quantity_unit_conversion_interaction_workflow, validation_workflow</workflow>
</chain> </chain>
<chain> <chain>
<type>Sale Supply</type> <type>Sale Supply</type>
......
...@@ -61,18 +61,27 @@ ...@@ -61,18 +61,27 @@
result = {}\n result = {}\n
for definition in context.portal_catalog(**kw):\n for definition in context.portal_catalog(**kw):\n
definition = definition.getObject()\n definition = definition.getObject()\n
definition_list = definition.getParentValue()\n if definition.getValidationState() != "validated":\n
standard_quantity_unit_uid = definition_list.getQuantityUnitUid()\n continue\n
\n
definition_group = definition.getParentValue()\n
if definition_group.getValidationState() != "validated":\n
continue\n
\n
standard_quantity_unit_uid = definition_group.getQuantityUnitUid()\n
if standard_quantity_unit_uid is None:\n if standard_quantity_unit_uid is None:\n
continue\n continue\n
\n \n
result[standard_quantity_unit_uid] = (None, 1.0)\n result[standard_quantity_unit_uid] = (None, 1.0)\n
\n
unit_uid = definition.getQuantityUnitUid()\n unit_uid = definition.getQuantityUnitUid()\n
if unit_uid is None:\n if unit_uid is None:\n
continue\n continue\n
\n
quantity = definition.getQuantity()\n quantity = definition.getQuantity()\n
if not quantity:\n if not quantity:\n
continue\n continue\n
\n
result[unit_uid] = (definition.getUid(), quantity)\n result[unit_uid] = (definition.getUid(), quantity)\n
\n \n
return result\n return result\n
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="InteractionDefinition" module="Products.ERP5.Interaction"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>actbox_category</string> </key>
<value> <string>workflow</string> </value>
</item>
<item>
<key> <string>actbox_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>actbox_url</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>activate_script_name</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>after_script_name</string> </key>
<value>
<list>
<string>QuantityUnitConversion_invalidateCache</string>
</list>
</value>
</item>
<item>
<key> <string>before_commit_script_name</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>guard</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>QuantityUnitConversion_invalidateCache</string> </value>
</item>
<item>
<key> <string>method_id</string> </key>
<value>
<list>
<string>invalidate</string>
<string>validate</string>
</list>
</value>
</item>
<item>
<key> <string>once_per_transaction</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>portal_type_filter</string> </key>
<value>
<list>
<string>Quantity Unit Conversion Definition</string>
<string>Quantity Unit Conversion Group</string>
</list>
</value>
</item>
<item>
<key> <string>script_name</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>invalidate Universal cache after object invalidation</string> </value>
</item>
<item>
<key> <string>trigger_type</string> </key>
<value> <int>2</int> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -59,7 +59,7 @@ grand_parent = modified.getParentValue().getParentValue()\n ...@@ -59,7 +59,7 @@ grand_parent = modified.getParentValue().getParentValue()\n
\n \n
activate_kw=dict(after_path=modified.getPath())\n activate_kw=dict(after_path=modified.getPath())\n
\n \n
if grand_parent.portal_type == "Product":\n if grand_parent.getPortalType() == "Product":\n
# If measure is local\n # If measure is local\n
grand_parent.reindexObject(activate_kw=activate_kw)\n grand_parent.reindexObject(activate_kw=activate_kw)\n
else:\n else:\n
......
<?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>modified = state_change[\'object\']\n
\n
scope = modified.getParentValue()\n
if scope.getPortalType() == "Quantity Unit Conversion Group":\n
scope = scope.getParentValue()\n
\n
if scope.getPortalType() != "Product":\n
# This was a global definition.\n
# Its change implies that all local definitions need reindexation\n
# Even resources that do NOT override definitions need indexation.\n
context.QuantityUnitConversionModule_invalidateUniversalDefinitionDict()\n
context.product_module.recursiveReindexObject()\n
else:\n
scope.reindexObject()\n
</string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>state_change</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>state_change</string>
<string>_getitem_</string>
<string>modified</string>
<string>_getattr_</string>
<string>scope</string>
<string>context</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>QuantityUnitConversion_invalidateCache</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
441 442
\ No newline at end of file \ No newline at end of file
...@@ -14,8 +14,10 @@ Purchase Supply | edit_workflow ...@@ -14,8 +14,10 @@ Purchase Supply | edit_workflow
Purchase Supply | validation_workflow Purchase Supply | validation_workflow
Quantity Unit Conversion Definition | edit_workflow Quantity Unit Conversion Definition | edit_workflow
Quantity Unit Conversion Definition | quantity_unit_conversion_interaction_workflow Quantity Unit Conversion Definition | quantity_unit_conversion_interaction_workflow
Quantity Unit Conversion Definition | validation_workflow
Quantity Unit Conversion Group | edit_workflow Quantity Unit Conversion Group | edit_workflow
Quantity Unit Conversion Group | quantity_unit_conversion_interaction_workflow Quantity Unit Conversion Group | quantity_unit_conversion_interaction_workflow
Quantity Unit Conversion Group | validation_workflow
Sale Supply Line | edit_workflow Sale Supply Line | edit_workflow
Sale Supply Line | supply_line_interaction_workflow Sale Supply Line | supply_line_interaction_workflow
Sale Supply | edit_workflow Sale Supply | edit_workflow
......
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