fix: disable pagination in draft link lookup

frappe.get_list defaults to 20 rows; child-table joins can produce
duplicate parent names that fill the window and hide further drafts.
Also clarify the check-ordering regression test.
This commit is contained in:
Nabin Hait
2026-07-22 12:06:00 +05:30
parent 7d351153bb
commit c522a1fdae
2 changed files with 5 additions and 2 deletions

View File

@@ -21,7 +21,7 @@ class DraftLinkFinder:
names: set[str] = set()
for filters in self._link_filters():
names.update(frappe.get_list(self.target_doctype, filters=filters, pluck="name"))
names.update(frappe.get_list(self.target_doctype, filters=filters, pluck="name", limit=0))
return sorted(names)
def _link_filters(self) -> Iterator[list]:

View File

@@ -36,7 +36,10 @@ class TestDraftLinks(ERPNextTestSuite):
self.assertIn(packing_slip.name, get_existing_drafts("Delivery Note", dn.name, "Packing Slip"))
def test_nonexistent_target_doctype_returns_empty_for_non_admin(self):
def test_nonexistent_target_doctype_does_not_raise_for_non_admin(self):
# guards check ordering: for non-Administrator users has_permission()
# raises DoesNotExistError on unknown doctypes, so existence must be
# checked first (Administrator short-circuits and would not catch this)
with self.set_user("test@example.com"):
drafts = get_existing_drafts("Sales Order", "SO-0001", "Inter Company Purchase Order")
self.assertEqual(drafts, [])