mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-25 16:04:46 +00:00
Merge pull request #49095 from frappe/mergify/bp/version-15-hotfix/pr-49088
fix: Include Employee party type in Receivable and Payable account filters (backport #49088)
This commit is contained in:
@@ -26,13 +26,27 @@ class PartyType(Document):
|
|||||||
@frappe.validate_and_sanitize_search_inputs
|
@frappe.validate_and_sanitize_search_inputs
|
||||||
def get_party_type(doctype, txt, searchfield, start, page_len, filters):
|
def get_party_type(doctype, txt, searchfield, start, page_len, filters):
|
||||||
cond = ""
|
cond = ""
|
||||||
|
account_type = None
|
||||||
|
|
||||||
if filters and filters.get("account"):
|
if filters and filters.get("account"):
|
||||||
account_type = frappe.db.get_value("Account", filters.get("account"), "account_type")
|
account_type = frappe.db.get_value("Account", filters.get("account"), "account_type")
|
||||||
cond = "and account_type = '%s'" % account_type
|
if account_type:
|
||||||
|
if account_type in ["Receivable", "Payable"]:
|
||||||
|
# Include Employee regardless of its configured account_type, but still respect the text filter
|
||||||
|
cond = "and (account_type = %(account_type)s or name = 'Employee')"
|
||||||
|
else:
|
||||||
|
cond = "and account_type = %(account_type)s"
|
||||||
|
|
||||||
return frappe.db.sql(
|
# Build parameters dictionary
|
||||||
|
params = {"txt": "%" + txt + "%", "start": start, "page_len": page_len}
|
||||||
|
if account_type:
|
||||||
|
params["account_type"] = account_type
|
||||||
|
|
||||||
|
result = frappe.db.sql(
|
||||||
f"""select name from `tabParty Type`
|
f"""select name from `tabParty Type`
|
||||||
where `{searchfield}` LIKE %(txt)s {cond}
|
where `{searchfield}` LIKE %(txt)s {cond}
|
||||||
order by name limit %(page_len)s offset %(start)s""",
|
order by name limit %(page_len)s offset %(start)s""",
|
||||||
{"txt": "%" + txt + "%", "start": start, "page_len": page_len},
|
params,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
return result or []
|
||||||
|
|||||||
Reference in New Issue
Block a user