diff --git a/master/bt5/vifib_slap/ExtensionTemplateItem/VifibUtil.py b/master/bt5/vifib_slap/ExtensionTemplateItem/VifibUtil.py index d24f6efeb707341680383832f23d3e4ad5877550..9acd396ac0cb64d6a01a9cafcde2dddaac89ad02 100644 --- a/master/bt5/vifib_slap/ExtensionTemplateItem/VifibUtil.py +++ b/master/bt5/vifib_slap/ExtensionTemplateItem/VifibUtil.py @@ -1,3 +1,42 @@ import hashlib +from Products.ERP5Type.UnrestrictedMethod import UnrestrictedMethod +from AccessControl.SecurityManagement import getSecurityManager, \ + setSecurityManager, newSecurityManager + def getSha512Hexdiest(s): return hashlib.sha512(s).hexdigest() + +@UnrestrictedMethod +def getComputerReference(item): + portal_type = item.getPortalType() + computer = None + + if portal_type == 'Software Installation': + computer = item.getAggregateValue(portal_type='Computer') + elif portal_type == 'Computer Partition': + computer = item.getParentValue() + elif portal_type in ['Software Instance', 'Slave Instance']: + partition = item.getAggregateValue(portal_type='Computer Partition') + if partition is not None: + computer = partition.getParentValue() + + if computer is not None and computer.getValidationState() == 'validated': + return computer.getReference() + return None + +def Item_activateFillComputerInformationCache(state_change): + item = state_change['object'] + portal = item.getPortalObject() + computer_reference = getComputerReference(item) + if computer_reference is None: + return None + + sm = getSecurityManager() + try: + newSecurityManager(None, + portal.acl_users.getUserById(computer_reference)) + for full in (True, False): + portal.portal_slap._activateFillComputerInformationCache( + computer_reference, computer_reference, full) + finally: + setSecurityManager(sm) diff --git a/master/bt5/vifib_slap/PortalTypeWorkflowChainTemplateItem/workflow_chain_type.xml b/master/bt5/vifib_slap/PortalTypeWorkflowChainTemplateItem/workflow_chain_type.xml index 78c525b72e7026d5a40c05564e791a70f279cde4..c86c07dcb9066c73bf13ae15a35f0f849febd901 100644 --- a/master/bt5/vifib_slap/PortalTypeWorkflowChainTemplateItem/workflow_chain_type.xml +++ b/master/bt5/vifib_slap/PortalTypeWorkflowChainTemplateItem/workflow_chain_type.xml @@ -35,6 +35,10 @@ <type>Sale Invoice Transaction</type> <workflow>slap_interaction_workflow</workflow> </chain> + <chain> + <type>Sale Order</type> + <workflow>slap_interaction_workflow</workflow> + </chain> <chain> <type>Sale Packing List</type> <workflow>slap_interaction_workflow</workflow> diff --git a/master/bt5/vifib_slap/WorkflowTemplateItem/portal_workflow/slap_interaction_workflow/interactions/HostingSubscription_reindexObject.xml b/master/bt5/vifib_slap/WorkflowTemplateItem/portal_workflow/slap_interaction_workflow/interactions/HostingSubscription_reindexObject.xml new file mode 100644 index 0000000000000000000000000000000000000000..ee113ba25b6f09450a3c2144c0760a4e8bad19fd --- /dev/null +++ b/master/bt5/vifib_slap/WorkflowTemplateItem/portal_workflow/slap_interaction_workflow/interactions/HostingSubscription_reindexObject.xml @@ -0,0 +1,97 @@ +<?xml version="1.0"?> +<ZopeData> + <record id="1" aka="AAAAAAAAAAE="> + <pickle> + <global name="InteractionDefinition" module="Products.ERP5.Interaction"/> + </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>HostingSubscription_triggerAlarm</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>HostingSubscription_reindexObject</string> </value> + </item> + <item> + <key> <string>method_id</string> </key> + <value> + <list> + <string>reindexObject</string> + <string>recursiveReindexObject</string> + </list> + </value> + </item> + <item> + <key> <string>once_per_transaction</string> </key> + <value> <int>1</int> </value> + </item> + <item> + <key> <string>portal_type_filter</string> </key> + <value> + <list> + <string>Hosting Subscription</string> + </list> + </value> + </item> + <item> + <key> <string>script_name</string> </key> + <value> + <tuple/> + </value> + </item> + <item> + <key> <string>temporary_document_disallowed</string> </key> + <value> <int>1</int> </value> + </item> + <item> + <key> <string>title</string> </key> + <value> <string></string> </value> + </item> + <item> + <key> <string>trigger_type</string> </key> + <value> <int>2</int> </value> + </item> + </dictionary> + </pickle> + </record> +</ZopeData> diff --git a/master/bt5/vifib_slap/WorkflowTemplateItem/portal_workflow/slap_interaction_workflow/interactions/Item_reindexObject.xml b/master/bt5/vifib_slap/WorkflowTemplateItem/portal_workflow/slap_interaction_workflow/interactions/Item_reindexObject.xml new file mode 100644 index 0000000000000000000000000000000000000000..8f9c273947325082be2b59fa20d6556081187e75 --- /dev/null +++ b/master/bt5/vifib_slap/WorkflowTemplateItem/portal_workflow/slap_interaction_workflow/interactions/Item_reindexObject.xml @@ -0,0 +1,100 @@ +<?xml version="1.0"?> +<ZopeData> + <record id="1" aka="AAAAAAAAAAE="> + <pickle> + <global name="InteractionDefinition" module="Products.ERP5.Interaction"/> + </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> + <tuple/> + </value> + </item> + <item> + <key> <string>before_commit_script_name</string> </key> + <value> + <list> + <string>Item_activateFillComputerInformationCache</string> + </list> + </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>Item_reindexObject</string> </value> + </item> + <item> + <key> <string>method_id</string> </key> + <value> + <list> + <string>reindexObject</string> + <string>recursiveReindexObject</string> + </list> + </value> + </item> + <item> + <key> <string>once_per_transaction</string> </key> + <value> <int>1</int> </value> + </item> + <item> + <key> <string>portal_type_filter</string> </key> + <value> + <list> + <string>Computer Partition</string> + <string>Slave Instance</string> + <string>Software Installation</string> + <string>Software Instance</string> + </list> + </value> + </item> + <item> + <key> <string>script_name</string> </key> + <value> + <tuple/> + </value> + </item> + <item> + <key> <string>temporary_document_disallowed</string> </key> + <value> <int>1</int> </value> + </item> + <item> + <key> <string>title</string> </key> + <value> <string></string> </value> + </item> + <item> + <key> <string>trigger_type</string> </key> + <value> <int>2</int> </value> + </item> + </dictionary> + </pickle> + </record> +</ZopeData> diff --git a/master/bt5/vifib_slap/WorkflowTemplateItem/portal_workflow/slap_interaction_workflow/interactions/SaleOrder_reindexObject.xml b/master/bt5/vifib_slap/WorkflowTemplateItem/portal_workflow/slap_interaction_workflow/interactions/SaleOrder_reindexObject.xml new file mode 100644 index 0000000000000000000000000000000000000000..3a2f1ae827235537aa04d5eb5e29b801c7467196 --- /dev/null +++ b/master/bt5/vifib_slap/WorkflowTemplateItem/portal_workflow/slap_interaction_workflow/interactions/SaleOrder_reindexObject.xml @@ -0,0 +1,97 @@ +<?xml version="1.0"?> +<ZopeData> + <record id="1" aka="AAAAAAAAAAE="> + <pickle> + <global name="InteractionDefinition" module="Products.ERP5.Interaction"/> + </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> + <tuple/> + </value> + </item> + <item> + <key> <string>before_commit_script_name</string> </key> + <value> + <list> + <string>SaleOrder_triggerAlarm</string> + </list> + </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>SaleOrder_reindexObject</string> </value> + </item> + <item> + <key> <string>method_id</string> </key> + <value> + <list> + <string>reindexObject</string> + <string>recursiveReindexObject</string> + </list> + </value> + </item> + <item> + <key> <string>once_per_transaction</string> </key> + <value> <int>1</int> </value> + </item> + <item> + <key> <string>portal_type_filter</string> </key> + <value> + <list> + <string>Sale Order</string> + </list> + </value> + </item> + <item> + <key> <string>script_name</string> </key> + <value> + <tuple/> + </value> + </item> + <item> + <key> <string>temporary_document_disallowed</string> </key> + <value> <int>1</int> </value> + </item> + <item> + <key> <string>title</string> </key> + <value> <string></string> </value> + </item> + <item> + <key> <string>trigger_type</string> </key> + <value> <int>2</int> </value> + </item> + </dictionary> + </pickle> + </record> +</ZopeData> diff --git a/master/bt5/vifib_slap/WorkflowTemplateItem/portal_workflow/slap_interaction_workflow/scripts/Alarm_safeTrigger.xml b/master/bt5/vifib_slap/WorkflowTemplateItem/portal_workflow/slap_interaction_workflow/scripts/Alarm_safeTrigger.xml new file mode 100644 index 0000000000000000000000000000000000000000..6ba06e94ac86c6c0aeb0fe2caa276e5d851887bf --- /dev/null +++ b/master/bt5/vifib_slap/WorkflowTemplateItem/portal_workflow/slap_interaction_workflow/scripts/Alarm_safeTrigger.xml @@ -0,0 +1,76 @@ +<?xml version="1.0"?> +<ZopeData> + <record id="1" aka="AAAAAAAAAAE="> + <pickle> + <global name="PythonScript" module="Products.PythonScripts.PythonScript"/> + </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>if alarm.getParentValue().isSubscribed() and not alarm.isActive() and alarm.isEnabled():\n + alarm.activeSense()\n +</string> </value> + </item> + <item> + <key> <string>_params</string> </key> + <value> <string>alarm</string> </value> + </item> + <item> + <key> <string>_proxy_roles</string> </key> + <value> + <tuple> + <string>Manager</string> + </tuple> + </value> + </item> + <item> + <key> <string>id</string> </key> + <value> <string>Alarm_safeTrigger</string> </value> + </item> + </dictionary> + </pickle> + </record> +</ZopeData> diff --git a/master/bt5/vifib_slap/WorkflowTemplateItem/portal_workflow/slap_interaction_workflow/scripts/HostingSubscription_triggerAlarm.xml b/master/bt5/vifib_slap/WorkflowTemplateItem/portal_workflow/slap_interaction_workflow/scripts/HostingSubscription_triggerAlarm.xml new file mode 100644 index 0000000000000000000000000000000000000000..7290bcf90c6b9b8590b43c9a998260caac4cc64e --- /dev/null +++ b/master/bt5/vifib_slap/WorkflowTemplateItem/portal_workflow/slap_interaction_workflow/scripts/HostingSubscription_triggerAlarm.xml @@ -0,0 +1,70 @@ +<?xml version="1.0"?> +<ZopeData> + <record id="1" aka="AAAAAAAAAAE="> + <pickle> + <global name="PythonScript" module="Products.PythonScripts.PythonScript"/> + </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>sale_order = state_change[\'object\']\n +\n +portal = sale_order.getPortalObject()\n +context.Alarm_safeTrigger(portal.portal_alarms.vifib_person_update_open_order)\n +</string> </value> + </item> + <item> + <key> <string>_params</string> </key> + <value> <string>state_change</string> </value> + </item> + <item> + <key> <string>id</string> </key> + <value> <string>HostingSubscription_triggerAlarm</string> </value> + </item> + </dictionary> + </pickle> + </record> +</ZopeData> diff --git a/master/bt5/vifib_slap/WorkflowTemplateItem/portal_workflow/slap_interaction_workflow/scripts/Item_activateFillComputerInformationCache.xml b/master/bt5/vifib_slap/WorkflowTemplateItem/portal_workflow/slap_interaction_workflow/scripts/Item_activateFillComputerInformationCache.xml new file mode 100644 index 0000000000000000000000000000000000000000..bdfadaf9f130e209b96a4abc826411ed495ff053 --- /dev/null +++ b/master/bt5/vifib_slap/WorkflowTemplateItem/portal_workflow/slap_interaction_workflow/scripts/Item_activateFillComputerInformationCache.xml @@ -0,0 +1,28 @@ +<?xml version="1.0"?> +<ZopeData> + <record id="1" aka="AAAAAAAAAAE="> + <pickle> + <global name="ExternalMethod" module="Products.ExternalMethod.ExternalMethod"/> + </pickle> + <pickle> + <dictionary> + <item> + <key> <string>_function</string> </key> + <value> <string>Item_activateFillComputerInformationCache</string> </value> + </item> + <item> + <key> <string>_module</string> </key> + <value> <string>VifibUtil</string> </value> + </item> + <item> + <key> <string>id</string> </key> + <value> <string>Item_activateFillComputerInformationCache</string> </value> + </item> + <item> + <key> <string>title</string> </key> + <value> <string></string> </value> + </item> + </dictionary> + </pickle> + </record> +</ZopeData> diff --git a/master/bt5/vifib_slap/WorkflowTemplateItem/portal_workflow/slap_interaction_workflow/scripts/SaleOrder_triggerAlarm.xml b/master/bt5/vifib_slap/WorkflowTemplateItem/portal_workflow/slap_interaction_workflow/scripts/SaleOrder_triggerAlarm.xml new file mode 100644 index 0000000000000000000000000000000000000000..524f08f5d822322c07badffac1c3e275f9df6b44 --- /dev/null +++ b/master/bt5/vifib_slap/WorkflowTemplateItem/portal_workflow/slap_interaction_workflow/scripts/SaleOrder_triggerAlarm.xml @@ -0,0 +1,79 @@ +<?xml version="1.0"?> +<ZopeData> + <record id="1" aka="AAAAAAAAAAE="> + <pickle> + <global name="PythonScript" module="Products.PythonScripts.PythonScript"/> + </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>sale_order = state_change[\'object\']\n +\n +portal = sale_order.getPortalObject()\n +\n +simulation_state = sale_order.getSimulationState()\n +alarm = None\n +if simulation_state == \'planned\':\n + alarm = portal.portal_alarms.order_planned_sale_order\n +elif simulation_state == \'ordered\':\n + alarm = portal.portal_alarms.confirm_ordered_sale_order\n +\n +if alarm is not None:\n + context.Alarm_safeTrigger(alarm)\n +</string> </value> + </item> + <item> + <key> <string>_params</string> </key> + <value> <string>state_change</string> </value> + </item> + <item> + <key> <string>id</string> </key> + <value> <string>SaleOrder_triggerAlarm</string> </value> + </item> + </dictionary> + </pickle> + </record> +</ZopeData> diff --git a/master/bt5/vifib_slap/bt/revision b/master/bt5/vifib_slap/bt/revision index 779a8736e2c9762c2e62590be40c16f5209c1589..cb225603316a1950cb97a32db5bb5c9e7a44618b 100644 --- a/master/bt5/vifib_slap/bt/revision +++ b/master/bt5/vifib_slap/bt/revision @@ -1 +1 @@ -826 \ No newline at end of file +827 \ No newline at end of file diff --git a/master/bt5/vifib_slap/bt/template_portal_type_workflow_chain_list b/master/bt5/vifib_slap/bt/template_portal_type_workflow_chain_list index 9d4671b8dbadbcd327d250918401b9051391fd05..c3306e58a9518544d61735ffa2ca3a94c87a4c40 100644 --- a/master/bt5/vifib_slap/bt/template_portal_type_workflow_chain_list +++ b/master/bt5/vifib_slap/bt/template_portal_type_workflow_chain_list @@ -9,6 +9,7 @@ Person | person_slap_interface_workflow Person | slap_interaction_workflow Purchase Packing List | slap_interaction_workflow Sale Invoice Transaction | slap_interaction_workflow +Sale Order | slap_interaction_workflow Sale Packing List Line | slap_interaction_workflow Sale Packing List | slap_interaction_workflow Slave Instance | slap_interaction_workflow