Commit 085cb207 authored by Jérome Perrin's avatar Jérome Perrin

Make sure we never delete all lines

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@6930 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent f105c8f1
...@@ -66,27 +66,34 @@ ...@@ -66,27 +66,34 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>"""\n <value> <string>"""Deletes all empty (ie. with balance == 0) lines in an accounting transaction\n
This script deletes all empty (ie. with balance == 0) lines in an accounting transaction\n
"""\n """\n
\n from Producs.ERP5Type.Message import Message\n
N_ = lambda msg: Message(\'erp5_ui\', msg)\n
lines_portal_type = context.getPortalAccountingMovementTypeList()\n lines_portal_type = context.getPortalAccountingMovementTypeList()\n
transaction = context.getObject()\n transaction = context.getObject()\n
transaction_lines = transaction.objectValues(portal_type=lines_portal_type)\n
id_to_delete_list = []\n
\n
\n \n
for line in transaction.objectValues(portal_type=lines_portal_type) :\n for line in transaction_lines:\n
line = line.getObject()\n line = line.getObject()\n
# Do not delete lines involved in simulation\n # Do not delete lines involved in simulation\n
if len( line.getDeliveryRelatedValueList(\n if len(line.getDeliveryRelatedValueList(\n
portal_type = \'Simulation Movement\') +\n portal_type = \'Simulation Movement\') +\n
line.getOrderRelatedValueList(\n line.getOrderRelatedValueList(\n
portal_type = \'Simulation Movement\') ) == 0 :\n portal_type = \'Simulation Movement\')) == 0:\n
if not line.getSourceInventoriatedTotalAssetPrice() and \\\n if not line.getSourceInventoriatedTotalAssetPrice() and \\\n
not line.getDestinationInventoriatedTotalAssetPrice() :\n not line.getDestinationInventoriatedTotalAssetPrice():\n
transaction.deleteContent(line.getId())\n id_to_delete_list.append(line.getId())\n
\n
if len(id_to_delete_list) != len(transaction_lines):\n
# Don\'t delete everything\n
transaction.deleteContents(id_to_delete_list)\n
\n \n
if redirect :\n if redirect:\n
context.REQUEST.RESPONSE.redirect("%s/view?portal_status_message=%s" % (\n context.REQUEST.RESPONSE.redirect("%s/view?portal_status_message=%s" % (\n
transaction.getPath(), context.Base_translateString(\'Empty Lines Deleted.\')))\n transaction.getPath(), N_(\'Empty+Lines+Deleted.\')))\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
...@@ -107,7 +114,7 @@ if redirect :\n ...@@ -107,7 +114,7 @@ if redirect :\n
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>redirect = 0</string> </value> <value> <string>redirect=0</string> </value>
</item> </item>
<item> <item>
<key> <string>errors</string> </key> <key> <string>errors</string> </key>
...@@ -134,10 +141,15 @@ if redirect :\n ...@@ -134,10 +141,15 @@ if redirect :\n
<value> <value>
<tuple> <tuple>
<string>redirect</string> <string>redirect</string>
<string>Producs.ERP5Type.Message</string>
<string>Message</string>
<string>N_</string>
<string>_getattr_</string> <string>_getattr_</string>
<string>context</string> <string>context</string>
<string>lines_portal_type</string> <string>lines_portal_type</string>
<string>transaction</string> <string>transaction</string>
<string>transaction_lines</string>
<string>id_to_delete_list</string>
<string>_getiter_</string> <string>_getiter_</string>
<string>line</string> <string>line</string>
<string>len</string> <string>len</string>
......
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