diff --git a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransactionModule_createReversalTransactionList.py b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransactionModule_createReversalTransactionList.py index f0db22c9ae7091c46edddf6858aaa958e5f01f0a..04e50c8c933bbeabc741e8e06542bb83cd08da1b 100644 --- a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransactionModule_createReversalTransactionList.py +++ b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransactionModule_createReversalTransactionList.py @@ -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, diff --git a/bt5/erp5_hal_json_style/ExtensionTemplateItem/portal_components/extension.erp5.HalStyle.py b/bt5/erp5_hal_json_style/ExtensionTemplateItem/portal_components/extension.erp5.HalStyle.py index 75b611997ae2604ce4dfb15f118589477c74b86a..fef4ad48b2fe8448ef1f8a0b30797e008fcf5987 100644 --- a/bt5/erp5_hal_json_style/ExtensionTemplateItem/portal_components/extension.erp5.HalStyle.py +++ b/bt5/erp5_hal_json_style/ExtensionTemplateItem/portal_components/extension.erp5.HalStyle.py @@ -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) diff --git a/bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/Base_redirect.py b/bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/Base_redirect.py index 925a2766ed9f46e62c9ad9ad7c11921b26d7e417..3814e7a63241a2ed40632958f8981a6787f9552a 100644 --- a/bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/Base_redirect.py +++ b/bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/Base_redirect.py @@ -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) diff --git a/bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/Base_redirect.xml b/bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/Base_redirect.xml index a2922863aaf4d0ea2c116c52aaa6623b346bbf38..b61dac5b983663f504090df525a03412ee9ff163 100644 --- a/bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/Base_redirect.xml +++ b/bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/Base_redirect.xml @@ -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> diff --git a/bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/Portal_abortTransaction.xml b/bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/Portal_abortTransaction.xml new file mode 100644 index 0000000000000000000000000000000000000000..07dfbb52a2adcf3dee6ef52fba5d2dd8eaa02813 --- /dev/null +++ b/bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/Portal_abortTransaction.xml @@ -0,0 +1,28 @@ +<?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>