Commit f5852e98 authored by Łukasz Nowak's avatar Łukasz Nowak

Simplify update script.

Just add not present yet causalities.
parent d7f9809e
...@@ -50,9 +50,7 @@ ...@@ -50,9 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[ <value> <string>"""This script is called on the Invoice after the delivery builder has created\n
"""This script is called on the Invoice after the delivery builder has created\n
the new Invoice.\n the new Invoice.\n
"""\n """\n
from Products.ERP5Type.Message import translateString\n from Products.ERP5Type.Message import translateString\n
...@@ -87,58 +85,20 @@ invoice.activate(after_path_and_method_id=(related_simulation_movement_path_list ...@@ -87,58 +85,20 @@ invoice.activate(after_path_and_method_id=(related_simulation_movement_path_list
(\'immediateReindexObject\',\'recursiveImmediateReindexObject\')),\n (\'immediateReindexObject\',\'recursiveImmediateReindexObject\')),\n
after_tag=plan_tag).updateCausalityState()\n after_tag=plan_tag).updateCausalityState()\n
\n \n
related_packing_list = invoice.getDefaultCausalityValue()\n # update casuality from movements\n
if related_packing_list is None:\n causality_list = invoice.getCausalityList()\n
# XXX: oink\n causality_list.sort()\n
return\n modified = 0\n
for movement in invoice.getMovementList(portal_type=\'Invoice Line\'):\n
movement_causality = movement.getCausality()\n
if movement_causality not in causality_list:\n
modified = 1\n
causality_list.append(movement_causality)\n
\n \n
related_order = related_packing_list.getDefaultCausalityValue()\n if modified:\n
if related_order is None:\n causality_list.sort()\n
# XXX: oink\n invoice.setCausalityList(causality_list)\n
return\n </string> </value>
\n
# copy payment conditions from packing list\n
# if missing, try to copy from order (for compatibility)\n
if not invoice.contentValues(portal_type=\'Payment Condition\'):\n
payment_condition_copy_id_list = []\n
if related_packing_list is not None:\n
payment_condition_copy_id_list = related_packing_list.contentIds(filter={\'portal_type\':\'Payment Condition\'})\n
if len(payment_condition_copy_id_list) > 0:\n
clipboard = related_packing_list.manage_copyObjects(ids=payment_condition_copy_id_list)\n
invoice.manage_pasteObjects(clipboard)\n
elif related_order is not None:\n
payment_condition_copy_id_list = related_order.contentIds(\n
filter={\'portal_type\':\'Payment Condition\'})\n
if len(payment_condition_copy_id_list) > 0:\n
clipboard = related_order.manage_copyObjects(ids=payment_condition_copy_id_list)\n
invoice.manage_pasteObjects(clipboard)\n
\n
if related_order is not None and context.portal_skins.hasObject(\'erp5_simulation_legacy\'):\n
# copy trade condition:\n
if not context.getSpecialise():\n
context.edit(specialise=related_order.getSpecialise())\n
\n
# copy order\'s trade model lines\n
invoice_trade_model_line_reference_list = [document.getReference() \\\n
for document in context.contentValues(portal_type=\'Trade Model Line\')]\n
order_trade_model_line_copy_id_list = []\n
for order_trade_model_line in related_order.contentValues(\n
portal_type=\'Trade Model Line\'):\n
if order_trade_model_line.getReference() not in \\\n
invoice_trade_model_line_reference_list:\n
order_trade_model_line_copy_id_list.append(order_trade_model_line.getId())\n
\n
if order_trade_model_line_copy_id_list:\n
clipboard = related_order.manage_copyObjects(\n
ids=order_trade_model_line_copy_id_list)\n
context.manage_pasteObjects(clipboard)\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
]]></string> </value>
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
......
344 345
\ No newline at end of file \ 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