mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-18 20:49:19 +00:00
fix: link field displays incorrect value when empty
(cherry picked from commit db00860662)
# Conflicts:
# erpnext/public/js/utils.js
This commit is contained in:
@@ -1036,6 +1036,7 @@ erpnext.utils.map_current_doc = function (opts) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
frappe.form.link_formatters["Item"] = function (value, doc) {
|
frappe.form.link_formatters["Item"] = function (value, doc) {
|
||||||
if (doc && value && doc.item_name && doc.item_name !== value && doc.item_code === value) {
|
if (doc && value && doc.item_name && doc.item_name !== value && doc.item_code === value) {
|
||||||
return value + ": " + doc.item_name;
|
return value + ": " + doc.item_name;
|
||||||
@@ -1045,6 +1046,38 @@ frappe.form.link_formatters["Item"] = function (value, doc) {
|
|||||||
} else {
|
} else {
|
||||||
// if value is blank in report view or item code and name are the same, return as is
|
// if value is blank in report view or item code and name are the same, return as is
|
||||||
return value;
|
return value;
|
||||||
|
=======
|
||||||
|
frappe.form.link_formatters["Item"] = function (value, doc, df) {
|
||||||
|
return add_link_title(value, doc, df, "item_name");
|
||||||
|
};
|
||||||
|
|
||||||
|
frappe.form.link_formatters["Employee"] = function (value, doc, df) {
|
||||||
|
return add_link_title(value, doc, df, "employee_name");
|
||||||
|
};
|
||||||
|
|
||||||
|
frappe.form.link_formatters["Project"] = function (value, doc, df) {
|
||||||
|
return add_link_title(value, doc, df, "project_name");
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a title to a link value based on the provided document and field information.
|
||||||
|
*
|
||||||
|
* @param {string} value - The value to add a link title to.
|
||||||
|
* @param {Object} doc - The document object.
|
||||||
|
* @param {Object} df - The field object.
|
||||||
|
* @param {string} title_field - The field name for the title.
|
||||||
|
* @returns {string} - The link value with the added title.
|
||||||
|
*/
|
||||||
|
function add_link_title(value, doc, df, title_field) {
|
||||||
|
if (value && doc[title_field]) {
|
||||||
|
if (doc[title_field] !== value && doc[df.fieldname] === value) {
|
||||||
|
return value + ": " + doc[title_field];
|
||||||
|
} else if (doc.doctype == df.parent) {
|
||||||
|
return doc[title_field];
|
||||||
|
} else {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
>>>>>>> db00860662 (fix: link field displays incorrect value when empty)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user