From d6511b00451e713d85b99e195ad9afb9b35ab962 Mon Sep 17 00:00:00 2001 From: SowmyaArunachalam Date: Fri, 2 Jan 2026 16:05:36 +0530 Subject: [PATCH] fix: add company filters to project (cherry picked from commit 7c16db567b50035c9e1dbc6dbed18ff7dd929a8b) # Conflicts: # erpnext/accounts/doctype/journal_entry/journal_entry.js --- .../doctype/journal_entry/journal_entry.js | 17 +++++++++++++++++ .../stock/doctype/stock_entry/stock_entry.js | 18 ++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.js b/erpnext/accounts/doctype/journal_entry/journal_entry.js index f04bf6b22b3..181edb4cd6b 100644 --- a/erpnext/accounts/doctype/journal_entry/journal_entry.js +++ b/erpnext/accounts/doctype/journal_entry/journal_entry.js @@ -20,6 +20,23 @@ frappe.ui.form.on("Journal Entry", { "Unreconcile Payment Entries", "Bank Transaction", ]; + frm.trigger("set_queries"); + }, + + set_queries(frm) { + frm.set_query("project", "accounts", function (doc, cdt, cdn) { + let row = frappe.get_doc(cdt, cdn); + let filters = { + company: doc.company, + }; + if (row.party_type == "Customer") { + filters.customer = row.party; + } + return { + query: "erpnext.controllers.queries.get_project_name", + filters, + }; + }); }, refresh: function (frm) { diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.js b/erpnext/stock/doctype/stock_entry/stock_entry.js index 80bc1a34d0d..b1a1cdece37 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.js +++ b/erpnext/stock/doctype/stock_entry/stock_entry.js @@ -140,6 +140,24 @@ frappe.ui.form.on("Stock Entry", { }; }); + frm.set_query("project", "items", function (doc) { + return { + query: "erpnext.controllers.queries.get_project_name", + filters: { + company: doc.company, + }, + }; + }); + + frm.set_query("project", function (doc) { + return { + query: "erpnext.controllers.queries.get_project_name", + filters: { + company: doc.company, + }, + }; + }); + frm.add_fetch("bom_no", "inspection_required", "inspection_required"); erpnext.accounts.dimensions.setup_dimension_filters(frm, frm.doctype);