From e3cf25ce9d8eb9e4e4db72e188a3267cb89dc4dc Mon Sep 17 00:00:00 2001 From: ljain112 Date: Wed, 19 Mar 2025 17:20:25 +0530 Subject: [PATCH] refactor: removed redundant message display for each item row cost center update --- erpnext/public/js/utils/sales_common.js | 29 ++++++++++++++++--------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/erpnext/public/js/utils/sales_common.js b/erpnext/public/js/utils/sales_common.js index 411ebf13e4..9d7a29f327 100644 --- a/erpnext/public/js/utils/sales_common.js +++ b/erpnext/public/js/utils/sales_common.js @@ -410,16 +410,25 @@ erpnext.sales_common = { if (["Delivery Note", "Sales Invoice", "Sales Order"].includes(this.frm.doc.doctype)) { if (this.frm.doc.project) { frappe.call({ - method:'erpnext.projects.doctype.project.project.get_cost_center_name' , - args: {project: this.frm.doc.project}, - callback: function(r, rt) { - if(!r.exc) { - $.each(me.frm.doc["items"] || [], function(i, row) { - if(r.message) { - frappe.model.set_value(row.doctype, row.name, "cost_center", r.message); - frappe.msgprint(__("Cost Center For Item with Item Code {0} has been Changed to {1}", [row.item_name, r.message])); - } - }) + method: "erpnext.projects.doctype.project.project.get_cost_center_name", + args: { project: this.frm.doc.project }, + callback: function (r, rt) { + if (!r.exc) { + if (r.message) { + $.each(me.frm.doc["items"] || [], function (i, row) { + frappe.model.set_value( + row.doctype, + row.name, + "cost_center", + r.message + ); + }); + frappe.msgprint( + __("Cost Center for Item rows has been updated to {0}", [ + r.message, + ]) + ); + } } } }) -- GitLab