diff --git a/bt5/erp5_trade/WorkflowTemplateItem/portal_workflow/packing_list_workflow/scripts/PackingList_buildInvoice.xml b/bt5/erp5_trade/WorkflowTemplateItem/portal_workflow/packing_list_workflow/scripts/PackingList_buildInvoice.xml index 891831d93ac22177b1fecba44478ab7552d9e1c2..4d7d06f140f6b2c2efc3d923a09c92dedba906c2 100644 --- a/bt5/erp5_trade/WorkflowTemplateItem/portal_workflow/packing_list_workflow/scripts/PackingList_buildInvoice.xml +++ b/bt5/erp5_trade/WorkflowTemplateItem/portal_workflow/packing_list_workflow/scripts/PackingList_buildInvoice.xml @@ -66,23 +66,25 @@ </item> <item> <key> <string>_body</string> </key> - <value> <string>LOG=lambda msg:context.log("PackingList_buildInvoice", msg)\n -LOG=lambda msg:\'DISABLED\'\n -\n -packing_list = sci.object\n + <value> <string>packing_list = sci[\'object\']\n delivery_tool = sci.getPortal().portal_deliveries\n -LOG("packing_list : %s"%packing_list.getPath())\n \n -if hasattr(delivery_tool, \'sale_invoice_builder\') :\n - delivery_tool.sale_invoice_builder.activate(\n - after_method_id = [ \'expand\', \n - \'recursiveImmediateReindexObject\',\n - \'immediateReindexObject\' ],\n - ).build()\n -else :\n - context.log("ERP5 Simulation",\n +found = 0\n +builder_id_list = [\'sale_invoice_builder\', \'purchase_invoice_builder\']\n +for builder_id in builder_id_list:\n + if hasattr(delivery_tool, builder_id):\n + found = 1\n + builder = getattr(delivery_tool, builder_id)\n + builder.activate(\n + after_method_id = [ \'expand\', \n + \'recursiveImmediateReindexObject\',\n + \'immediateReindexObject\' ],\n + ).build()\n +\n +if not found:\n + packing_list.log("ERP5 Simulation",\n "Unable to build Invoice from packing list at %s "\\\n - ": no sale_invoice_builder" % packing_list.getPath())\n + ": no builder" % packing_list.getPath())\n </string> </value> </item> <item> @@ -130,12 +132,17 @@ else :\n <value> <tuple> <string>sci</string> - <string>LOG</string> - <string>_getattr_</string> + <string>_getitem_</string> <string>packing_list</string> + <string>_getattr_</string> <string>delivery_tool</string> + <string>found</string> + <string>builder_id_list</string> + <string>_getiter_</string> + <string>builder_id</string> <string>hasattr</string> - <string>context</string> + <string>getattr</string> + <string>builder</string> </tuple> </value> </item> diff --git a/bt5/erp5_trade/WorkflowTemplateItem/portal_workflow/packing_list_workflow/scripts/PackingList_updateAppliedRule.xml b/bt5/erp5_trade/WorkflowTemplateItem/portal_workflow/packing_list_workflow/scripts/PackingList_updateAppliedRule.xml index 796a09e9a285b339805e7e298fc994ef02b01912..d9043d875b3e03edbcb82801164386f2e8dfda47 100644 --- a/bt5/erp5_trade/WorkflowTemplateItem/portal_workflow/packing_list_workflow/scripts/PackingList_updateAppliedRule.xml +++ b/bt5/erp5_trade/WorkflowTemplateItem/portal_workflow/packing_list_workflow/scripts/PackingList_updateAppliedRule.xml @@ -66,11 +66,7 @@ </item> <item> <key> <string>_body</string> </key> - <value> <string>LOG=lambda msg:context.log("PackingList_updateAppliedRule", msg)\n -LOG=lambda msg:\'DISABLED\'\n -\n -packing_list = state_change.object\n -\n + <value> <string>packing_list = state_change[\'object\']\n \n activate_kw = {}\n related_order = context.getCausalityValue()\n @@ -137,10 +133,10 @@ packing_list.activate(\n <tuple> <string>state_change</string> <string>kw</string> - <string>LOG</string> - <string>_getattr_</string> + <string>_getitem_</string> <string>packing_list</string> <string>activate_kw</string> + <string>_getattr_</string> <string>context</string> <string>related_order</string> <string>after_path_list</string>