feat: add an argument pass mechanism to bulk transactions
This commit is contained in:
@@ -7,12 +7,15 @@ from frappe.utils import get_link_to_form, today
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
def transaction_processing(data, from_doctype, to_doctype):
|
||||
def transaction_processing(data, from_doctype, to_doctype, args=None):
|
||||
if isinstance(data, str):
|
||||
deserialized_data = json.loads(data)
|
||||
else:
|
||||
deserialized_data = data
|
||||
|
||||
if isinstance(args, str):
|
||||
args = frappe._dict(json.loads(args))
|
||||
|
||||
length_of_data = len(deserialized_data)
|
||||
|
||||
frappe.msgprint(
|
||||
@@ -23,6 +26,7 @@ def transaction_processing(data, from_doctype, to_doctype):
|
||||
deserialized_data=deserialized_data,
|
||||
from_doctype=from_doctype,
|
||||
to_doctype=to_doctype,
|
||||
args=args,
|
||||
)
|
||||
|
||||
|
||||
@@ -71,8 +75,13 @@ def update_log(log_name, status, retried, err=None):
|
||||
frappe.db.set_value("Bulk Transaction Log Detail", log_name, "error_description", err)
|
||||
|
||||
|
||||
def job(deserialized_data, from_doctype, to_doctype):
|
||||
def job(deserialized_data, from_doctype, to_doctype, args):
|
||||
fail_count = 0
|
||||
|
||||
if args:
|
||||
# currently: flag-based transport to `task`
|
||||
frappe.flags.args = args
|
||||
|
||||
for d in deserialized_data:
|
||||
try:
|
||||
doc_name = d.get("name")
|
||||
|
||||
Reference in New Issue
Block a user