fix: index error on customer master
This commit is contained in:
parent
2e2590b224
commit
cf1e3dc8ea
@ -6,7 +6,7 @@ import json
|
|||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
import frappe.defaults
|
import frappe.defaults
|
||||||
from frappe import _, msgprint
|
from frappe import _, msgprint, qb
|
||||||
from frappe.contacts.address_and_contact import (
|
from frappe.contacts.address_and_contact import (
|
||||||
delete_contact_and_address,
|
delete_contact_and_address,
|
||||||
load_address_and_contact,
|
load_address_and_contact,
|
||||||
@ -732,12 +732,15 @@ def make_address(args, is_primary_address=1):
|
|||||||
@frappe.validate_and_sanitize_search_inputs
|
@frappe.validate_and_sanitize_search_inputs
|
||||||
def get_customer_primary_contact(doctype, txt, searchfield, start, page_len, filters):
|
def get_customer_primary_contact(doctype, txt, searchfield, start, page_len, filters):
|
||||||
customer = filters.get("customer")
|
customer = filters.get("customer")
|
||||||
return frappe.db.sql(
|
|
||||||
"""
|
con = qb.DocType("Contact")
|
||||||
select `tabContact`.name from `tabContact`, `tabDynamic Link`
|
dlink = qb.DocType("Dynamic Link")
|
||||||
where `tabContact`.name = `tabDynamic Link`.parent and `tabDynamic Link`.link_name = %(customer)s
|
|
||||||
and `tabDynamic Link`.link_doctype = 'Customer'
|
return (
|
||||||
and `tabContact`.name like %(txt)s
|
qb.from_(con)
|
||||||
""",
|
.join(dlink)
|
||||||
{"customer": customer, "txt": "%%%s%%" % txt},
|
.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…
x
Reference in New Issue
Block a user