Commit cdeefdd9 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

deleteContent should be called in this script that has proxy roles.

parent a1818daa
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</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>"""Deletes all empty (ie. with balance == 0) lines in an accounting transaction\n
"""\n
from Products.ERP5Type.Message import translateString\n
lines_portal_type = context.getPortalAccountingMovementTypeList()\n
transaction = context.getObject()\n
transaction_lines = transaction.objectValues(portal_type=lines_portal_type)\n
id_to_delete_list = []\n
\n
for line in transaction_lines:\n
if line.getSourceInventoriatedTotalAssetPrice() or \\\n
line.getDestinationInventoriatedTotalAssetPrice() or \\\n
line.isSimulated():\n
continue\n
id_to_delete_list.append(line.getId())\n
\n
# Don\'t delete everything\n
if len(id_to_delete_list) != len(transaction_lines):\n
transaction.deleteContent(id_to_delete_list)\n
\n
if redirect:\n
context.REQUEST.RESPONSE.redirect("%s/view?portal_status_message=%s" % (\n
transaction.absolute_url(), translateString(\'Empty lines deleted.\')))\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>redirect=0</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>AccountingTransaction_deleteEmptyLines</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -70,8 +70,9 @@ container.validateTransaction(state_change)\n
\n
# Check that all lines uses open accounts, and doesn\'t use invalid third\n
# parties or bank accounts\n
for line in transaction.contentValues(filter=dict(\n
portal_type=transaction.getPortalAccountingMovementTypeList())):\n
transaction_lines = transaction.objectValues(portal_type=transaction.getPortalAccountingMovementTypeList())\n
id_to_delete_list = []\n
for line in transaction_lines:\n
\n
for account, third_party, bank_account in (\n
( line.getSourceValue(portal_type=\'Account\'),\n
......@@ -139,9 +140,17 @@ for line in transaction.contentValues(filter=dict(\n
line.getDestinationInventoriatedTotalAssetDebit())):\n
raise ValidationFailed(translateString(\n
"Destination conversion should not be set."))\n
\n
if line.getSourceInventoriatedTotalAssetPrice() or \\\n
line.getDestinationInventoriatedTotalAssetPrice() or \\\n
line.isSimulated():\n
continue\n
id_to_delete_list.append(line.getId())\n
\n
# Delete empty lines\n
transaction.AccountingTransaction_deleteEmptyLines(redirect=0)\n
# Don\'t delete everything\n
if len(id_to_delete_list) != len(transaction_lines):\n
transaction.deleteContent(id_to_delete_list)\n
</string> </value>
</item>
<item>
......
1466
\ No newline at end of file
1467
\ No newline at end of file
......@@ -70,8 +70,9 @@ container.validateTransaction(state_change)\n
\n
# Check that all lines uses open accounts, and doesn\'t use invalid third\n
# parties or bank accounts\n
for line in transaction.contentValues(filter=dict(\n
portal_type=transaction.getPortalAccountingMovementTypeList())):\n
transaction_lines = transaction.objectValues(portal_type=transaction.getPortalAccountingMovementTypeList())\n
id_to_delete_list = []\n
for line in transaction_lines:\n
\n
for account, third_party, bank_account in (\n
( line.getSourceValue(portal_type=\'Account\'),\n
......@@ -139,9 +140,17 @@ for line in transaction.contentValues(filter=dict(\n
line.getDestinationInventoriatedTotalAssetDebit())):\n
raise ValidationFailed(translateString(\n
"Destination conversion should not be set."))\n
\n
if line.getSourceInventoriatedTotalAssetPrice() or \\\n
line.getDestinationInventoriatedTotalAssetPrice() or \\\n
line.isSimulated():\n
continue\n
id_to_delete_list.append(line.getId())\n
\n
# Delete empty lines\n
transaction.AccountingTransaction_deleteEmptyLines(redirect=0)\n
# Don\'t delete everything\n
if len(id_to_delete_list) != len(transaction_lines):\n
transaction.deleteContent(id_to_delete_list)\n
</string> </value>
</item>
<item>
......
5
\ No newline at end of file
6
\ 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