Hyper Open Edge Cloud

How To Use Delivery Causality Workflow

How To showing how to use delivery_causality_workflow for another portal type.
  • Last Update:2016-09-07
  • Version:001
  • Language:en

After r23647 (2008-09-16), one 'delivery_causality_workflow' can be used for various portal types.

Table of Contents

Steps

We provide a script and External method that rename workflow name in workflow history on existing documents.

To use delivery_causality_workflow for another portal type, you need the following 'Type-based Script' (like SalePackingList_getBuilderList).

(PortalType)_getBuilderList

   returns the list of delivery builders that creates this portal type's document.

(PortalType)_getRuleReference

   returns the reference of the rule that should be applied to this portal type. If no applied rule is required, return None.

a script and a external method for migrating *_causality_workflow

Save the following as 'External Method' and register as 'mergeCausalityWorkflowHistory'.

Toggle line numbers
   1 from Products.ERP5Type.patches.WorkflowTool import WorkflowHistoryList
   2 
   3 def mergeCausalityWorkflowHistory(self):
   4   wf_list = []
   5   workflow_history = getattr(self, 'workflow_history', None)
   6   if workflow_history is None:
   7     return 'no history'
   8   for k, v in workflow_history.items():
   9     if k.endswith('_causality_workflow'):
  10       wf_list.extend(v)
  11       del(self.workflow_history[k])
  12   wf_list.sort(key=lambda x:x['time'])
  13   if len(wf_list):
  14     self.workflow_history['delivery_causality_workflow'] = \
  15       WorkflowHistoryList(wf_list)
  16   return 'done'
Toggle line numbers from Products.ERP5Type.patches.WorkflowTool import WorkflowHistoryList def mergeCausalityWorkflowHistory(self): wf_list = [] workflow_history = getattr(self, 'workflow_history', None) if workflow_history is None: return 'no history' for k, v in workflow_history.items(): if k.endswith('_causality_workflow'): wf_list.extend(v) del(self.workflow_history[k]) wf_list.sort(key=lambda x:x['time']) if len(wf_list): self.workflow_history['delivery_causality_workflow'] = \ WorkflowHistoryList(wf_list) return 'done'

Save the following as 'Script (Python)'. Please modify portal_type list according to your ERP5 instance. Then invoke it to migrate all documents that now use delivery_causality_workflow. You need to restart ERP5 after this migration.

Toggle line numbers
   1 for i in context.getPortalObject().portal_catalog(
   2   portal_type=('Internal Packing List',
   3                'Pay Sheet Transaction',
   4                'Production Packing List',
   5                'Production Report',
   6                'Purchase Invoice Transaction',
   7                'Purchase Packing List',
   8                'Sale Invoice Transaction',
   9                'Sale Packing List',
  10                'Task Report',
  11                ), limit=None):
  12   i.activate(priority=4).mergeCausalityWorkflowHistory()
  13   print i.getPath()
  14 return printed

Toggle line numbers for i in context.getPortalObject().portal_catalog( portal_type=('Internal Packing List', 'Pay Sheet Transaction', 'Production Packing List', 'Production Report', 'Purchase Invoice Transaction', 'Purchase Packing List', 'Sale Invoice Transaction', 'Sale Packing List', 'Task Report', ), limit=None): i.activate(priority=4).mergeCausalityWorkflowHistory() print i.getPath() return printed

Related Articles