ERP5 KM

HowToUseDeliveryCausalityWorkflow

How to use delivery_causality_workflow

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

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'.

   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'] = \
      WorkflowHistoryList(wf_list)
  15   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.

   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

HowToUseDeliveryCausalityWorkflow (last edited 2008-11-05 14:03:16 by kazuhiko)

Page
  • Immutable Page
  • Info
  • Attachments
User
Learn about new ERP5 releases,technical articles, events and more.

Subscribe to the monthly ERP5 Newsletter!