From d550b433c1e3f32c0c8efee0be026b174511c8f6 Mon Sep 17 00:00:00 2001 From: venkat102 Date: Mon, 30 Dec 2024 14:18:13 +0530 Subject: [PATCH 1/2] fix: add company filter to project (cherry picked from commit 1a7b09e576ae47a654606b286d632b26f80fda59) --- .../accounts/doctype/payment_entry/payment_entry.js | 12 ++++++++++++ erpnext/public/js/controllers/buying.js | 8 ++++++++ 2 files changed, 20 insertions(+) diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.js b/erpnext/accounts/doctype/payment_entry/payment_entry.js index 8fd5f00b583..4a45007d50a 100644 --- a/erpnext/accounts/doctype/payment_entry/payment_entry.js +++ b/erpnext/accounts/doctype/payment_entry/payment_entry.js @@ -27,6 +27,18 @@ frappe.ui.form.on("Payment Entry", { erpnext.accounts.dimensions.setup_dimension_filters(frm, frm.doctype); + // project excluded in setup_dimension_filters + frm.set_query("project", function (doc) { + let filters = { + company: doc.company, + }; + if (doc.party_type == "Customer") filters.customer = doc.party; + return { + query: "erpnext.controllers.queries.get_project_name", + filters, + }; + }); + if (frm.is_new()) { set_default_party_type(frm); } diff --git a/erpnext/public/js/controllers/buying.js b/erpnext/public/js/controllers/buying.js index 5a8b63f601f..af61d5f0258 100644 --- a/erpnext/public/js/controllers/buying.js +++ b/erpnext/public/js/controllers/buying.js @@ -25,6 +25,14 @@ erpnext.buying = { }; }); + this.frm.set_query("project", function (doc) { + return { + filters: { + company: doc.company, + }, + }; + }); + if (this.frm.doc.__islocal && frappe.meta.has_field(this.frm.doc.doctype, "disable_rounded_total")) { From 74220430e537c40ca6b0af1dffe0412f23ef8c99 Mon Sep 17 00:00:00 2001 From: venkat102 Date: Mon, 30 Dec 2024 14:18:55 +0530 Subject: [PATCH 2/2] fix: include company in filter condition (cherry picked from commit b92f8bc5149a8db7d6d095687576325b013df1d9) --- erpnext/controllers/queries.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/erpnext/controllers/queries.py b/erpnext/controllers/queries.py index 463cb859970..03852d3739a 100644 --- a/erpnext/controllers/queries.py +++ b/erpnext/controllers/queries.py @@ -271,10 +271,14 @@ def get_project_name(doctype, txt, searchfield, start, page_len, filters): qb_filter_or_conditions = [] ifelse = CustomFunction("IF", ["condition", "then", "else"]) - if filters and filters.get("customer"): - qb_filter_and_conditions.append( - (proj.customer == filters.get("customer")) | proj.customer.isnull() | proj.customer == "" - ) + if filters: + if filters.get("customer"): + qb_filter_and_conditions.append( + (proj.customer == filters.get("customer")) | proj.customer.isnull() | proj.customer == "" + ) + + if filters.get("company"): + qb_filter_and_conditions.append(proj.company == filters.get("company")) qb_filter_and_conditions.append(proj.status.notin(["Completed", "Cancelled"]))