fix: pass reference_doctype to search query methods (#20842)
frappe.call ensures that it's only passed to functions which can accept it, so nothing to worry about ~ backward compatible change.
This commit is contained in:
parent
e6279e08f2
commit
109a549a23
2 changed files with 29 additions and 1 deletions
|
|
@ -81,7 +81,15 @@ def search_widget(
|
|||
try:
|
||||
is_whitelisted(frappe.get_attr(query))
|
||||
frappe.response["values"] = frappe.call(
|
||||
query, doctype, txt, searchfield, start, page_length, filters, as_dict=as_dict
|
||||
query,
|
||||
doctype,
|
||||
txt,
|
||||
searchfield,
|
||||
start,
|
||||
page_length,
|
||||
filters,
|
||||
as_dict=as_dict,
|
||||
reference_doctype=reference_doctype,
|
||||
)
|
||||
except frappe.exceptions.PermissionError as e:
|
||||
if frappe.local.conf.developer_mode:
|
||||
|
|
|
|||
|
|
@ -130,12 +130,32 @@ class TestSearch(FrappeTestCase):
|
|||
search_link("User", "user@random", searchfield="name")
|
||||
self.assertListEqual(frappe.response["results"], [])
|
||||
|
||||
def test_reference_doctype(self):
|
||||
"""search query methods should get reference_doctype if they want"""
|
||||
search_link(
|
||||
doctype="User",
|
||||
txt="",
|
||||
filters=None,
|
||||
page_length=20,
|
||||
reference_doctype="ToDo",
|
||||
query="frappe.tests.test_search.query_with_reference_doctype",
|
||||
)
|
||||
self.assertListEqual(frappe.response["results"], [])
|
||||
|
||||
|
||||
@frappe.validate_and_sanitize_search_inputs
|
||||
def get_data(doctype, txt, searchfield, start, page_len, filters):
|
||||
return [doctype, txt, searchfield, start, page_len, filters]
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
@frappe.validate_and_sanitize_search_inputs
|
||||
def query_with_reference_doctype(
|
||||
doctype, txt, searchfield, start, page_len, filters, reference_doctype=None
|
||||
):
|
||||
return []
|
||||
|
||||
|
||||
def setup_test_link_field_order(TestCase):
|
||||
TestCase.tree_doctype_name = "Test Tree Order"
|
||||
TestCase.child_doctype_list = []
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue