Commit 15d6e5c6 authored by Jérome Perrin's avatar Jérome Perrin

merge InvoiceTransaction_postGenerationActivity into...

merge InvoiceTransaction_postGenerationActivity into InvoiceTransaction_postGeneration it's no longer required to wait for activities to set causality

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@25382 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent f953da59
......@@ -53,32 +53,62 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>#\n
# this script is called on the Invoice after the delivery builder has created\n
# the new Invoice.\n
# it calls InvoiceTransaction_postGenerationActivity when indexing is done \n
#\n
<value> <string>"""This script is called on the Invoice after the delivery builder has created\n
the new Invoice.\n
"""\n
from Products.ERP5Type.Message import translateString\n
try:\n
from Products.CMFCore.WorkflowCore import WorkflowException\n
except ImportError:\n
# WorkflowException has not always been allowed in restricted\n
# environment, in this case, make sure WorkflowException is \n
# defined \n
class WorkflowException(Exception):\n
pass\n
\n
if related_simulation_movement_path_list is None:\n
raise RuntimeError, \'related_simulation_movement_path_list is missing. Update ERP5 Product.\'\n
\n
activate_kw = dict(\n
after_path_and_method_id=(related_simulation_movement_path_list,\n
(\'immediateReindexObject\',\'recursiveImmediateReindexObject\')),)\n
\n
invoice = context\n
packing_list = invoice.getCausalityValue()\n
if packing_list is not None:\n
order = packing_list.getCausalityValue()\n
if order is not None:\n
invoice.setSpecialise(order.getSpecialise())\n
# this is tax tag from packing_list_workflow scripts\n
activate_kw[\'after_tag\'] = \'build_invoice_tax_%s\' % packing_list.getRelativeUrl()\n
\n
invoice.activate(\n
**activate_kw\n
).InvoiceTransaction_postGenerationActivity(\n
related_simulation_movement_path_list=related_simulation_movement_path_list, **kw)\n
# set resource from price currency\n
if not invoice.getResource():\n
invoice.setResource(invoice.getPriceCurrency())\n
\n
related_packing_list = invoice.getDefaultCausalityValue()\n
\n
# copy trade condition:\n
if not context.getSpecialise():\n
related_order = related_packing_list.getDefaultCausalityValue()\n
if related_order is not None:\n
context.edit(specialise=related_order.getSpecialise())\n
\n
# copy title, if not updating a new delivery\n
if not invoice.hasTitle() and related_packing_list.hasTitle():\n
invoice.setTitle(related_packing_list.getTitle())\n
\n
# initialize accounting_workflow to confirmed state\n
if invoice.getSimulationState() == \'draft\':\n
try :\n
context.getPortalObject().portal_workflow.doActionFor(\n
invoice, \'confirm_action\',\n
comment=translateString(\'Initialized by Delivery Builder.\'),\n
skip_period_validation=1)\n
except WorkflowException, e:\n
# The user cannot pass the transition, it\'s OK\n
pass\n
\n
if invoice.getSimulationState() == \'draft\':\n
# call the workflow method, if the user cannot perform this operation.\n
invoice.confirm(comment=translateString(\'Initialized by Delivery Builder.\'),)\n
\n
\n
# First set the invoice in the building state on the causality workflow\n
invoice.startBuilding()\n
\n
# Then an activity should put the causality state in diverged or solved\n
invoice.activate(after_path_and_method_id=(related_simulation_movement_path_list,\n
(\'immediateReindexObject\',\'recursiveImmediateReindexObject\'))).updateCausalityState()\n
</string> </value>
</item>
<item>
......@@ -117,17 +147,20 @@ invoice.activate(\n
<tuple>
<string>related_simulation_movement_path_list</string>
<string>kw</string>
<string>Products.ERP5Type.Message</string>
<string>translateString</string>
<string>Products.CMFCore.WorkflowCore</string>
<string>WorkflowException</string>
<string>ImportError</string>
<string>Exception</string>
<string>None</string>
<string>RuntimeError</string>
<string>dict</string>
<string>activate_kw</string>
<string>context</string>
<string>invoice</string>
<string>_getattr_</string>
<string>packing_list</string>
<string>order</string>
<string>_write_</string>
<string>_apply_</string>
<string>related_packing_list</string>
<string>related_order</string>
<string>e</string>
</tuple>
</value>
</item>
......
<?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>#\n
# this script is called in an activity on the Sale Invoice Transaction\n
# after the invoice_builder delivery builder has created\n
# the new Sale Invoice Transaction\n
#\n
from Products.ERP5Type.Message import translateString\n
try:\n
from Products.CMFCore.WorkflowCore import WorkflowException\n
except ImportError:\n
# WorkflowException has not always been allowed in restricted\n
# environment, in this case, make sure WorkflowException is \n
# defined \n
class WorkflowException(Exception):\n
pass\n
\n
# Return Message object, so that this message will be translated when it is rendered later.\n
\n
invoice = context\n
from Products.ERP5Type.Log import log\n
LOG = lambda msg:log(\n
"InvoiceTransaction_postGenerationActivity on %s" % (invoice.getPath()), msg)\n
\n
related_packing_list = invoice.getDefaultCausalityValue()\n
#LOG(\'causality %s \' %invoice.getCausalityValueList())\n
\n
# XXX this use of currency is completly bogus, it should be set on simulation movements.\n
# get a price_currency from the packing list, or the order\n
price_currency = related_packing_list.getPriceCurrency()\n
if price_currency:\n
invoice.edit(\n
resource=price_currency,\n
price_currency=price_currency,)\n
else:\n
related_order = related_packing_list.getDefaultCausalityValue()\n
if related_order is not None:\n
price_currency = related_order.getPriceCurrency()\n
invoice.edit(\n
resource=price_currency,\n
price_currency=price_currency,)\n
\n
\n
# copy trade condition:\n
if not context.getSpecialise():\n
related_order = related_packing_list.getDefaultCausalityValue()\n
if related_order is not None:\n
context.edit(specialise=related_order.getSpecialise())\n
\n
# copy title, if not updating a new delivery\n
if not invoice.hasTitle() and related_packing_list.hasTitle():\n
invoice.setTitle(related_packing_list.getTitle())\n
\n
# initialize accounting_workflow to planned state\n
if invoice.getSimulationState() == \'draft\':\n
try :\n
context.getPortalObject().portal_workflow.doActionFor(\n
invoice, \'confirm_action\',\n
comment=translateString(\'Initialized by Delivery Builder.\'),\n
skip_period_validation=1)\n
except WorkflowException, e:\n
# The user cannot pass the transition, it\'s OK\n
pass\n
\n
if invoice.getSimulationState() == \'draft\':\n
# call the workflow method, if the user cannot perform this operation.\n
invoice.confirm()\n
\n
# First set the invoice in the building state on the causality workflow\n
invoice.startBuilding()\n
\n
# Then an activity should put the causality state in diverged or solved\n
invoice.activate(after_path_and_method_id=(related_simulation_movement_path_list,\n
(\'immediateReindexObject\',\'recursiveImmediateReindexObject\'))).updateCausalityState()\n
</string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>related_simulation_movement_path_list=None, **kw</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>related_simulation_movement_path_list</string>
<string>kw</string>
<string>Products.ERP5Type.Message</string>
<string>translateString</string>
<string>Products.CMFCore.WorkflowCore</string>
<string>WorkflowException</string>
<string>ImportError</string>
<string>Exception</string>
<string>context</string>
<string>invoice</string>
<string>Products.ERP5Type.Log</string>
<string>log</string>
<string>LOG</string>
<string>_getattr_</string>
<string>related_packing_list</string>
<string>price_currency</string>
<string>related_order</string>
<string>None</string>
<string>e</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<tuple>
<none/>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>InvoiceTransaction_postGenerationActivity</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
194
\ No newline at end of file
196
\ No newline at end of file
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