refactor: build document links with get_form_link in report formatters

This commit is contained in:
diptanilsaha
2026-08-18 22:49:45 +05:30
parent 57c2887ab4
commit cfb664804c
2 changed files with 9 additions and 3 deletions

View File

@@ -23,7 +23,10 @@ frappe.query_reports["Production Plan Summary"] = {
if (column.fieldname == "item_code") {
var color = data.pending_qty > 0 ? "red" : "green";
value = `<a style='color:${color}' href="/app/item/${data["item_code"]}" data-doctype="Item">${data["item_code"]}</a>`;
value = `<a style='color:${color}' href="${frappe.utils.get_form_link(
"Item",
data["item_code"]
)}" data-doctype="Item">${frappe.utils.escape_html(data["item_code"])}</a>`;
}
return value;

View File

@@ -68,7 +68,7 @@ frappe.query_reports["Serial No and Batch Traceability"] = {
function getTraceabilityLink({ type, value, original_value, item_code, data, filter_values }) {
if (!value) return value;
const base_url = type === "batch_no" ? "/app/batch/" : "/app/serial-no/";
const link_doctype = type === "batch_no" ? "Batch" : "Serial No";
const filter_list = filter_values[type]; // either batches or serial_nos
let css_class = "ellipsis";
@@ -84,7 +84,10 @@ function getTraceabilityLink({ type, value, original_value, item_code, data, fil
css_class = data.direction === "Backward" ? "ellipsis text-success" : "ellipsis text-danger";
}
return `<a class="${css_class}" href="${base_url}${original_value}">${original_value}</a>`;
return `<a class="${css_class}" href="${frappe.utils.get_form_link(
link_doctype,
original_value
)}">${frappe.utils.escape_html(original_value)}</a>`;
}
function custom_formatter(value, row, column, data, default_formatter) {