From a09b73e65d98253f1a6f370504cb6408bed87496 Mon Sep 17 00:00:00 2001 From: SowmyaArunachalam Date: Wed, 21 Jan 2026 16:11:04 +0530 Subject: [PATCH 1/3] fix(sales order): set project at item level from parent (cherry picked from commit 9e51701e2ad34d4410d5f68ebfdebe77e86141c0) --- erpnext/public/js/utils/sales_common.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/erpnext/public/js/utils/sales_common.js b/erpnext/public/js/utils/sales_common.js index 7e2271dc38f..cd59fc5ff0f 100644 --- a/erpnext/public/js/utils/sales_common.js +++ b/erpnext/public/js/utils/sales_common.js @@ -488,7 +488,16 @@ erpnext.sales_common = { } } - project() { + project(doc, cdt, cdn) { + var item = frappe.get_doc(cdt, cdn); + if (item.project) { + $.each(this.frm.doc["items"] || [], function (i, other_item) { + if (!other_item.project) { + other_item.project = item.project; + refresh_field("project", other_item.name, other_item.parentfield); + } + }); + } let me = this; if (["Delivery Note", "Sales Invoice", "Sales Order"].includes(this.frm.doc.doctype)) { if (this.frm.doc.project) { From e12564daa6101ce083f18cd09e3aa908f4d854a3 Mon Sep 17 00:00:00 2001 From: SowmyaArunachalam Date: Tue, 27 Jan 2026 11:36:51 +0530 Subject: [PATCH 2/3] chore: use frappe.model.set_value (cherry picked from commit 3b27f49d795d8634f5925fe9804df3d79e54904c) --- erpnext/public/js/utils/sales_common.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/erpnext/public/js/utils/sales_common.js b/erpnext/public/js/utils/sales_common.js index cd59fc5ff0f..1adbe402744 100644 --- a/erpnext/public/js/utils/sales_common.js +++ b/erpnext/public/js/utils/sales_common.js @@ -489,12 +489,16 @@ erpnext.sales_common = { } project(doc, cdt, cdn) { - var item = frappe.get_doc(cdt, cdn); + const item = frappe.get_doc(cdt, cdn); if (item.project) { $.each(this.frm.doc["items"] || [], function (i, other_item) { if (!other_item.project) { - other_item.project = item.project; - refresh_field("project", other_item.name, other_item.parentfield); + frappe.model.set_value( + other_item.doctype, + other_item.name, + "project", + item.project + ); } }); } From 7146c0385cdf13322c80ff8daf112dfc4856d295 Mon Sep 17 00:00:00 2001 From: SowmyaArunachalam Date: Tue, 27 Jan 2026 15:37:14 +0530 Subject: [PATCH 3/3] fix: handle parent level project change (cherry picked from commit 543b6e51c08f281bd733cd0d0ceb44a480f9cf35) --- erpnext/public/js/utils/sales_common.js | 34 ++++++++++++++++--------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/erpnext/public/js/utils/sales_common.js b/erpnext/public/js/utils/sales_common.js index 1adbe402744..c9b5ed7e6f2 100644 --- a/erpnext/public/js/utils/sales_common.js +++ b/erpnext/public/js/utils/sales_common.js @@ -489,18 +489,28 @@ erpnext.sales_common = { } project(doc, cdt, cdn) { - const item = frappe.get_doc(cdt, cdn); - if (item.project) { - $.each(this.frm.doc["items"] || [], function (i, other_item) { - if (!other_item.project) { - frappe.model.set_value( - other_item.doctype, - other_item.name, - "project", - item.project - ); - } - }); + if (!cdt || !cdn) { + if (this.frm.doc.project) { + $.each(this.frm.doc["items"] || [], function (i, item) { + if (!item.project) { + frappe.model.set_value(item.doctype, item.name, "project", doc.project); + } + }); + } + } else { + const item = frappe.get_doc(cdt, cdn); + if (item.project) { + $.each(this.frm.doc["items"] || [], function (i, other_item) { + if (!other_item.project) { + frappe.model.set_value( + other_item.doctype, + other_item.name, + "project", + item.project + ); + } + }); + } } let me = this; if (["Delivery Note", "Sales Invoice", "Sales Order"].includes(this.frm.doc.doctype)) {