seitime-frappe/frappe/patches/v13_0/queryreport_columns.py
2023-12-18 18:27:39 +05:30

18 lines
518 B
Python

# Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and Contributors
# License: MIT. See LICENSE
import json
import frappe
def execute():
"""Convert Query Report json to support other content."""
records = frappe.get_all("Report", filters={"json": ["!=", ""]}, fields=["name", "json"])
for record in records:
jstr = record["json"]
data = json.loads(jstr)
if isinstance(data, list):
# double escape braces
jstr = f'{{"columns":{jstr}}}'
frappe.db.set_value("Report", record["name"], "json", jstr)