fix: invalid dynamic link filter for address doctype (backport #53849) (#53852)

This commit is contained in:
mergify[bot]
2026-03-27 12:45:50 +00:00
committed by GitHub
parent 9a2851f221
commit 1c1369fea8
2 changed files with 27 additions and 4 deletions

View File

@@ -1002,3 +1002,26 @@ def get_item_uom_query(doctype, txt, searchfield, start, page_len, filters):
limit_page_length=page_len,
as_list=1,
)
@frappe.whitelist()
@frappe.validate_and_sanitize_search_inputs
def get_warehouse_address(doctype: str, txt: str, searchfield: str, start: int, page_len: int, filters: dict):
table = frappe.qb.DocType(doctype)
child_table = frappe.qb.DocType("Dynamic Link")
query = (
frappe.qb.from_(table)
.inner_join(child_table)
.on((table.name == child_table.parent) & (child_table.parenttype == doctype))
.select(table.name)
.where(
(child_table.link_name == filters.get("warehouse"))
& (table.disabled == 0)
& (child_table.link_doctype == "Warehouse")
& (table.name.like(f"%{txt}%"))
)
.offset(start)
.limit(page_len)
)
return query.run(as_list=1)

View File

@@ -38,18 +38,18 @@ frappe.ui.form.on("Stock Entry", {
frm.set_query("source_warehouse_address", function () {
return {
query: "erpnext.controllers.queries.get_warehouse_address",
filters: {
link_doctype: "Warehouse",
link_name: frm.doc.from_warehouse,
warehouse: frm.doc.from_warehouse,
},
};
});
frm.set_query("target_warehouse_address", function () {
return {
query: "erpnext.controllers.queries.get_warehouse_address",
filters: {
link_doctype: "Warehouse",
link_name: frm.doc.to_warehouse,
warehouse: frm.doc.to_warehouse,
},
};
});