refactor: rollback for retries and UI alerts
diff --git a/erpnext/bulk_transaction/doctype/bulk_transaction_log/bulk_transaction_log.js b/erpnext/bulk_transaction/doctype/bulk_transaction_log/bulk_transaction_log.js
index 6e22500..3135d41 100644
--- a/erpnext/bulk_transaction/doctype/bulk_transaction_log/bulk_transaction_log.js
+++ b/erpnext/bulk_transaction/doctype/bulk_transaction_log/bulk_transaction_log.js
@@ -12,7 +12,7 @@
if (frm.doc.failed) {
frm.add_custom_button(__('Retry Failed Transactions'), function() {
frappe.call({
- method: "erpnext.utilities.bulk_transaction.retry_failed_transactions",
+ method: "erpnext.utilities.bulk_transaction.retry",
args: {date: frm.doc.date}
}).then(()=> { });
});
diff --git a/erpnext/utilities/bulk_transaction.py b/erpnext/utilities/bulk_transaction.py
index a596001..7e73c2f 100644
--- a/erpnext/utilities/bulk_transaction.py
+++ b/erpnext/utilities/bulk_transaction.py
@@ -3,7 +3,7 @@
import frappe
from frappe import _
-from frappe.utils import today
+from frappe.utils import get_link_to_form, today
@frappe.whitelist()
@@ -30,7 +30,7 @@
@frappe.whitelist()
-def retry_failed_transactions(date: str | None):
+def retry(date: str | None):
if date:
failed_docs = frappe.db.get_all(
"Bulk Transaction Log Detail",
@@ -38,9 +38,21 @@
fields=["name", "transaction_name", "from_doctype", "to_doctype"],
)
if not failed_docs:
- frappe.msgprint("There are no Failed transactions")
- return
+ frappe.msgprint(_("There are no Failed transactions"))
+ else:
+ job = frappe.enqueue(
+ retry_failed_transactions,
+ failed_docs=failed_docs,
+ )
+ frappe.msgprint(
+ _("Job: {0} has been triggered for processing failed transactions").format(
+ get_link_to_form("RQ Job", job.id)
+ )
+ )
+
+def retry_failed_transactions(failed_docs: list | None):
+ if failed_docs:
for log in failed_docs:
try:
frappe.db.savepoint("before_creation_state")