Commit 1454f3a0 authored by Tomáš Peterka's avatar Tomáš Peterka

[hal_json] Support aborting transaction

parent 57623b4d
......@@ -24,9 +24,12 @@ for obj in object_list:
obj = obj.getObject()
if countMessage(path=obj.getPath(),
method_id='AccountingTransaction_createReversalTransaction'):
raise Redirect, "%s/view?portal_status_message=%s" % (
context.absolute_url(), translateString(
'Reversal creation already in progress, abandon.'))
return context.Base_redirect(form_id,
abort_transaction=True,
keep_items={
"portal_status_message": translateString('Reversal creation already in progress, abandon.'),
"portal_status_level": 'error'
})
obj.activate(tag=tag).AccountingTransaction_createReversalTransaction(
cancellation_amount=cancellation_amount,
date=date,
......
......@@ -9,6 +9,10 @@ def Base_aqBase(self):
def Base_aqInner(self):
return aq_inner(self)
def Portal_abortTransaction(self):
import transaction
transaction.abort()
def Field_getSubFieldKeyDict(self, field, field_id, key=None):
"""XXX"""
return field.generate_subfield_key(field_id, key=key)
......
......@@ -6,6 +6,11 @@
from ZTUtils import make_query
import json
if abort_transaction:
# Old UI simply throws a Redirect exception and Published does its job
# but we cannot use it here so we abort using External Method
context.getPortalObject().Portal_abortTransaction()
request_form = context.REQUEST.form
request_form.update(kw)
request_form = context.ERP5Site_filterParameterList(request_form)
......
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>form_id=\'view\', keep_items={}, **kw</string> </value>
<value> <string>form_id=\'view\', keep_items={}, abort_transaction=False, **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ExternalMethod" module="Products.ExternalMethod.ExternalMethod"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_function</string> </key>
<value> <string>Portal_abortTransaction</string> </value>
</item>
<item>
<key> <string>_module</string> </key>
<value> <string>HalStyle</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Portal_abortTransaction</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Abort Current Transaction</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
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