mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-29 09:54:47 +00:00
fix: using python instead of sql query
This commit is contained in:
@@ -1,21 +1,24 @@
|
|||||||
|
import json
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
|
|
||||||
|
|
||||||
def execute():
|
def execute():
|
||||||
frappe.db.sql(
|
custom_reports = frappe.get_all(
|
||||||
"""
|
"Report",
|
||||||
UPDATE `tabReport`
|
filters={
|
||||||
SET `json` = JSON_SET(
|
"report_type": "Custom Report",
|
||||||
JSON_REMOVE(json, '$.filters.group_by'),
|
"reference_report": ["in", ["General Ledger", "Supplier Quotation Comparison"]],
|
||||||
'$.filters.categorize_by',
|
},
|
||||||
REPLACE(JSON_UNQUOTE(JSON_EXTRACT(json, '$.filters.group_by')), 'Group', 'Categorize')
|
fields=["name", "json"],
|
||||||
)
|
|
||||||
WHERE
|
|
||||||
JSON_CONTAINS_PATH(json, 'one', '$.filters.group_by')
|
|
||||||
AND `reference_report` = CASE
|
|
||||||
WHEN `reference_report` = 'Supplier Quotation Comparison' THEN 'Supplier Quotation Comparison'
|
|
||||||
ELSE 'General Ledger'
|
|
||||||
END
|
|
||||||
AND `report_type` = 'Custom Report'
|
|
||||||
"""
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
for report in custom_reports:
|
||||||
|
report_json = json.loads(report.json)
|
||||||
|
|
||||||
|
if "filters" in report_json and "group_by" in report_json["filters"]:
|
||||||
|
report_json["filters"]["categorize_by"] = (
|
||||||
|
report_json["filters"].pop("group_by").replace("Group", "Categorize")
|
||||||
|
)
|
||||||
|
|
||||||
|
frappe.db.set_value("Report", report.name, "json", json.dumps(report_json))
|
||||||
|
|||||||
Reference in New Issue
Block a user