From b0fc568c80ec5bead83fc0bc61be78e95ba24813 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Thu, 3 Nov 2022 11:24:58 +0530 Subject: [PATCH] fix: not able to select customer / supplier --- erpnext/buying/doctype/supplier/test_supplier.py | 4 ++++ erpnext/controllers/queries.py | 4 ++-- erpnext/selling/doctype/customer/test_customer.py | 4 ++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/erpnext/buying/doctype/supplier/test_supplier.py b/erpnext/buying/doctype/supplier/test_supplier.py index e2dbf21be2c..b9fc344647b 100644 --- a/erpnext/buying/doctype/supplier/test_supplier.py +++ b/erpnext/buying/doctype/supplier/test_supplier.py @@ -156,6 +156,8 @@ class TestSupplier(FrappeTestCase): def test_serach_fields_for_supplier(self): from erpnext.controllers.queries import supplier_query + frappe.db.set_value("Buying Settings", None, "supp_master_name", "Naming Series") + supplier_name = create_supplier(supplier_name="Test Supplier 1").name make_property_setter( @@ -187,6 +189,8 @@ class TestSupplier(FrappeTestCase): self.assertEqual(data[0].supplier_type, "Company") self.assertTrue("supplier_type" in data[0]) + frappe.db.set_value("Buying Settings", None, "supp_master_name", "Supplier Name") + def create_supplier(**args): args = frappe._dict(args) diff --git a/erpnext/controllers/queries.py b/erpnext/controllers/queries.py index 3bdc0170682..b0cf7241669 100644 --- a/erpnext/controllers/queries.py +++ b/erpnext/controllers/queries.py @@ -85,7 +85,7 @@ def customer_query(doctype, txt, searchfield, start, page_len, filters, as_dict= fields = ["name"] if cust_master_name != "Customer Name": - fields = ["customer_name"] + fields.append("customer_name") fields = get_fields(doctype, fields) searchfields = frappe.get_meta(doctype).get_search_fields() @@ -123,7 +123,7 @@ def supplier_query(doctype, txt, searchfield, start, page_len, filters, as_dict= fields = ["name"] if supp_master_name != "Supplier Name": - fields = ["supplier_name"] + fields.append("supplier_name") fields = get_fields(doctype, fields) diff --git a/erpnext/selling/doctype/customer/test_customer.py b/erpnext/selling/doctype/customer/test_customer.py index 691adccd4dd..a621c737ed3 100644 --- a/erpnext/selling/doctype/customer/test_customer.py +++ b/erpnext/selling/doctype/customer/test_customer.py @@ -345,6 +345,8 @@ class TestCustomer(FrappeTestCase): def test_serach_fields_for_customer(self): from erpnext.controllers.queries import customer_query + frappe.db.set_value("Selling Settings", None, "cust_master_name", "Naming Series") + make_property_setter( "Customer", None, "search_fields", "customer_group", "Data", for_doctype="Doctype" ) @@ -369,6 +371,8 @@ class TestCustomer(FrappeTestCase): self.assertEqual(data[0].territory, "_Test Territory") self.assertTrue("territory" in data[0]) + frappe.db.set_value("Selling Settings", None, "cust_master_name", "Customer Name") + def get_customer_dict(customer_name): return {