feat: add an argument pass mechanism to bulk transactions
This commit is contained in:
parent
4832175341
commit
ffd38362d5
@ -1,7 +1,7 @@
|
|||||||
frappe.provide("erpnext.bulk_transaction_processing");
|
frappe.provide("erpnext.bulk_transaction_processing");
|
||||||
|
|
||||||
$.extend(erpnext.bulk_transaction_processing, {
|
$.extend(erpnext.bulk_transaction_processing, {
|
||||||
create: function(listview, from_doctype, to_doctype) {
|
create: function(listview, from_doctype, to_doctype, args) {
|
||||||
let checked_items = listview.get_checked_items();
|
let checked_items = listview.get_checked_items();
|
||||||
const doc_name = [];
|
const doc_name = [];
|
||||||
checked_items.forEach((Item)=> {
|
checked_items.forEach((Item)=> {
|
||||||
@ -15,7 +15,7 @@ $.extend(erpnext.bulk_transaction_processing, {
|
|||||||
if (doc_name.length == 0) {
|
if (doc_name.length == 0) {
|
||||||
frappe.call({
|
frappe.call({
|
||||||
method: "erpnext.utilities.bulk_transaction.transaction_processing",
|
method: "erpnext.utilities.bulk_transaction.transaction_processing",
|
||||||
args: {data: checked_items, from_doctype: from_doctype, to_doctype: to_doctype}
|
args: {data: checked_items, from_doctype: from_doctype, to_doctype: to_doctype, args: args}
|
||||||
}).then(()=> {
|
}).then(()=> {
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -7,12 +7,15 @@ from frappe.utils import get_link_to_form, today
|
|||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def transaction_processing(data, from_doctype, to_doctype):
|
def transaction_processing(data, from_doctype, to_doctype, args=None):
|
||||||
if isinstance(data, str):
|
if isinstance(data, str):
|
||||||
deserialized_data = json.loads(data)
|
deserialized_data = json.loads(data)
|
||||||
else:
|
else:
|
||||||
deserialized_data = data
|
deserialized_data = data
|
||||||
|
|
||||||
|
if isinstance(args, str):
|
||||||
|
args = frappe._dict(json.loads(args))
|
||||||
|
|
||||||
length_of_data = len(deserialized_data)
|
length_of_data = len(deserialized_data)
|
||||||
|
|
||||||
frappe.msgprint(
|
frappe.msgprint(
|
||||||
@ -23,6 +26,7 @@ def transaction_processing(data, from_doctype, to_doctype):
|
|||||||
deserialized_data=deserialized_data,
|
deserialized_data=deserialized_data,
|
||||||
from_doctype=from_doctype,
|
from_doctype=from_doctype,
|
||||||
to_doctype=to_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)
|
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
|
fail_count = 0
|
||||||
|
|
||||||
|
if args:
|
||||||
|
# currently: flag-based transport to `task`
|
||||||
|
frappe.flags.args = args
|
||||||
|
|
||||||
for d in deserialized_data:
|
for d in deserialized_data:
|
||||||
try:
|
try:
|
||||||
doc_name = d.get("name")
|
doc_name = d.get("name")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user