From 7b6e8b9c29fd166147dc7c6b3780c137b6244e2c Mon Sep 17 00:00:00 2001 From: UmakanthKaspa Date: Mon, 13 Jan 2025 14:46:53 +0000 Subject: [PATCH 1/2] feat: show item name alongside item code in the update items dialog --- erpnext/public/js/utils.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/erpnext/public/js/utils.js b/erpnext/public/js/utils.js index 088a3329f1f..63f405cc8f7 100755 --- a/erpnext/public/js/utils.js +++ b/erpnext/public/js/utils.js @@ -622,6 +622,7 @@ erpnext.utils.update_child_items = function (opts) { docname: d.name, name: d.name, item_code: d.item_code, + item_name: d.item_name, delivery_date: d.delivery_date, schedule_date: d.schedule_date, conversion_factor: d.conversion_factor, @@ -723,7 +724,30 @@ erpnext.utils.update_child_items = function (opts) { } }, }); + + const item_code = this.value; + if (item_code) { + frappe.db.get_value("Item", item_code, "item_name", (r) => { + if (r && r.item_name) { + const idx = this.doc.idx; + dialog.fields_dict.trans_items.df.data.some((doc) => { + if (doc.idx === idx) { + doc.item_name = r.item_name; + dialog.fields_dict.trans_items.grid.refresh(); + return true; + } + }); + } + }); + } }, + + }, + { + fieldtype: "Data", + fieldname: "item_name", + label: __("Item Name"), + read_only: 1, }, { fieldtype: "Link", From d762180231ac8133174648c4342e2c9eaa07d5ba Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Mon, 3 Feb 2025 16:45:12 +0530 Subject: [PATCH 2/2] refactor: reuse values from `get_item_details` --- erpnext/public/js/utils.js | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/erpnext/public/js/utils.js b/erpnext/public/js/utils.js index 63f405cc8f7..a77d96575eb 100755 --- a/erpnext/public/js/utils.js +++ b/erpnext/public/js/utils.js @@ -707,7 +707,13 @@ erpnext.utils.update_child_items = function (opts) { }, callback: function (r) { if (r.message) { - const { qty, price_list_rate: rate, uom, conversion_factor } = r.message; + const { + qty, + price_list_rate: rate, + uom, + conversion_factor, + item_name, + } = r.message; const row = dialog.fields_dict.trans_items.df.data.find( (doc) => doc.idx == me.doc.idx @@ -718,30 +724,14 @@ erpnext.utils.update_child_items = function (opts) { uom: me.doc.uom || uom, qty: me.doc.qty || qty, rate: me.doc.rate || rate, + item_name: item_name, }); dialog.fields_dict.trans_items.grid.refresh(); } } }, }); - - const item_code = this.value; - if (item_code) { - frappe.db.get_value("Item", item_code, "item_name", (r) => { - if (r && r.item_name) { - const idx = this.doc.idx; - dialog.fields_dict.trans_items.df.data.some((doc) => { - if (doc.idx === idx) { - doc.item_name = r.item_name; - dialog.fields_dict.trans_items.grid.refresh(); - return true; - } - }); - } - }); - } }, - }, { fieldtype: "Data",