|
@@ -36,7 +36,10 @@ def get_report_doc(report_name): |
|
|
reference_report = custom_report_doc.reference_report |
|
|
reference_report = custom_report_doc.reference_report |
|
|
doc = frappe.get_doc("Report", reference_report) |
|
|
doc = frappe.get_doc("Report", reference_report) |
|
|
doc.custom_report = report_name |
|
|
doc.custom_report = report_name |
|
|
doc.custom_columns = custom_report_doc.json |
|
|
|
|
|
|
|
|
if custom_report_doc.json: |
|
|
|
|
|
data = json.loads(custom_report_doc.json) |
|
|
|
|
|
if data: |
|
|
|
|
|
doc.custom_columns = data["columns"] |
|
|
doc.is_custom_report = True |
|
|
doc.is_custom_report = True |
|
|
|
|
|
|
|
|
if not doc.is_permitted(): |
|
|
if not doc.is_permitted(): |
|
@@ -83,7 +86,7 @@ def generate_report_result(report, filters=None, user=None, custom_columns=None) |
|
|
|
|
|
|
|
|
if report.custom_columns: |
|
|
if report.custom_columns: |
|
|
# saved columns (with custom columns / with different column order) |
|
|
# saved columns (with custom columns / with different column order) |
|
|
columns = json.loads(report.custom_columns) |
|
|
|
|
|
|
|
|
columns = report.custom_columns |
|
|
|
|
|
|
|
|
# unsaved custom_columns |
|
|
# unsaved custom_columns |
|
|
if custom_columns: |
|
|
if custom_columns: |
|
@@ -524,9 +527,12 @@ def save_report(reference_report, report_name, columns): |
|
|
"report_type": "Custom Report", |
|
|
"report_type": "Custom Report", |
|
|
}, |
|
|
}, |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
if docname: |
|
|
if docname: |
|
|
report = frappe.get_doc("Report", docname) |
|
|
report = frappe.get_doc("Report", docname) |
|
|
report.update({"json": columns}) |
|
|
|
|
|
|
|
|
existing_jd = json.loads(report.json) |
|
|
|
|
|
existing_jd["columns"] = json.loads(columns) |
|
|
|
|
|
report.update({"json": json.dumps(existing_jd, separators=(',', ':'))}) |
|
|
report.save() |
|
|
report.save() |
|
|
frappe.msgprint(_("Report updated successfully")) |
|
|
frappe.msgprint(_("Report updated successfully")) |
|
|
|
|
|
|
|
@@ -536,7 +542,7 @@ def save_report(reference_report, report_name, columns): |
|
|
{ |
|
|
{ |
|
|
"doctype": "Report", |
|
|
"doctype": "Report", |
|
|
"report_name": report_name, |
|
|
"report_name": report_name, |
|
|
"json": columns, |
|
|
|
|
|
|
|
|
"json": f'{{"columns":{columns}}}', |
|
|
"ref_doctype": report_doc.ref_doctype, |
|
|
"ref_doctype": report_doc.ref_doctype, |
|
|
"is_standard": "No", |
|
|
"is_standard": "No", |
|
|
"report_type": "Custom Report", |
|
|
"report_type": "Custom Report", |
|
|