fix: Supplier Primary Contact (backport ) ()

fix: Supplier `Primary Contact`

(cherry picked from commit 627165dc7c6c1cd83d746b97c82210abeb9a2e29)

Co-authored-by: s-aga-r <sagarsharma.s312@gmail.com>
This commit is contained in:
mergify[bot] 2023-11-23 11:13:32 +05:30 committed by GitHub
parent fb4235c528
commit 37d1f1ac67
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -165,16 +165,17 @@ class Supplier(TransactionBase):
@frappe.validate_and_sanitize_search_inputs @frappe.validate_and_sanitize_search_inputs
def get_supplier_primary_contact(doctype, txt, searchfield, start, page_len, filters): def get_supplier_primary_contact(doctype, txt, searchfield, start, page_len, filters):
supplier = filters.get("supplier") supplier = filters.get("supplier")
return frappe.db.sql( contact = frappe.qb.DocType("Contact")
""" dynamic_link = frappe.qb.DocType("Dynamic Link")
SELECT
`tabContact`.name from `tabContact`, return (
`tabDynamic Link` frappe.qb.from_(contact)
WHERE .join(dynamic_link)
`tabContact`.name = `tabDynamic Link`.parent .on(contact.name == dynamic_link.parent)
and `tabDynamic Link`.link_name = %(supplier)s .select(contact.name, contact.email_id)
and `tabDynamic Link`.link_doctype = 'Supplier' .where(
and `tabContact`.name like %(txt)s (dynamic_link.link_name == supplier)
""", & (dynamic_link.link_doctype == "Supplier")
{"supplier": supplier, "txt": "%%%s%%" % txt}, & (contact.name.like("%{0}%".format(txt)))
) )
).run(as_dict=False)