Merge pull request #33254 from ruthra-kumar/index_error_on_customer_master
fix: index error on customer master
This commit is contained in:
commit
1d37c0143f
@ -6,7 +6,7 @@ import json
|
||||
|
||||
import frappe
|
||||
import frappe.defaults
|
||||
from frappe import _, msgprint
|
||||
from frappe import _, msgprint, qb
|
||||
from frappe.contacts.address_and_contact import (
|
||||
delete_contact_and_address,
|
||||
load_address_and_contact,
|
||||
@ -732,12 +732,15 @@ def make_address(args, is_primary_address=1):
|
||||
@frappe.validate_and_sanitize_search_inputs
|
||||
def get_customer_primary_contact(doctype, txt, searchfield, start, page_len, filters):
|
||||
customer = filters.get("customer")
|
||||
return frappe.db.sql(
|
||||
"""
|
||||
select `tabContact`.name from `tabContact`, `tabDynamic Link`
|
||||
where `tabContact`.name = `tabDynamic Link`.parent and `tabDynamic Link`.link_name = %(customer)s
|
||||
and `tabDynamic Link`.link_doctype = 'Customer'
|
||||
and `tabContact`.name like %(txt)s
|
||||
""",
|
||||
{"customer": customer, "txt": "%%%s%%" % txt},
|
||||
|
||||
con = qb.DocType("Contact")
|
||||
dlink = qb.DocType("Dynamic Link")
|
||||
|
||||
return (
|
||||
qb.from_(con)
|
||||
.join(dlink)
|
||||
.on(con.name == dlink.parent)
|
||||
.select(con.name, con.full_name, con.email_id)
|
||||
.where((dlink.link_name == customer) & (con.name.like(f"%{txt}%")))
|
||||
.run()
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user