mirror of
https://github.com/frappe/erpnext.git
synced 2026-03-30 17:42:32 +02:00
fix: incorrect query filter when selecting primary customer adr (#50727)
(cherry picked from commit c2b8b97d7d)
# Conflicts:
# erpnext/selling/doctype/customer/customer.json
This commit is contained in:
@@ -41,18 +41,20 @@ frappe.ui.form.on("Supplier", {
|
|||||||
|
|
||||||
frm.set_query("supplier_primary_contact", function (doc) {
|
frm.set_query("supplier_primary_contact", function (doc) {
|
||||||
return {
|
return {
|
||||||
query: "erpnext.buying.doctype.supplier.supplier.get_supplier_primary_contact",
|
query: "erpnext.buying.doctype.supplier.supplier.get_supplier_primary",
|
||||||
filters: {
|
filters: {
|
||||||
supplier: doc.name,
|
supplier: doc.name,
|
||||||
|
type: "Contact",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
frm.set_query("supplier_primary_address", function (doc) {
|
frm.set_query("supplier_primary_address", function (doc) {
|
||||||
return {
|
return {
|
||||||
|
query: "erpnext.buying.doctype.supplier.supplier.get_supplier_primary",
|
||||||
filters: {
|
filters: {
|
||||||
link_doctype: "Supplier",
|
supplier: doc.name,
|
||||||
link_name: doc.name,
|
type: "Address",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -215,19 +215,25 @@ class Supplier(TransactionBase):
|
|||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
@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(doctype, txt, searchfield, start, page_len, filters):
|
||||||
supplier = filters.get("supplier")
|
supplier = filters.get("supplier")
|
||||||
contact = frappe.qb.DocType("Contact")
|
type = filters.get("type")
|
||||||
|
type_doctype = frappe.qb.DocType(type)
|
||||||
dynamic_link = frappe.qb.DocType("Dynamic Link")
|
dynamic_link = frappe.qb.DocType("Dynamic Link")
|
||||||
|
|
||||||
return (
|
query = (
|
||||||
frappe.qb.from_(contact)
|
frappe.qb.from_(type_doctype)
|
||||||
.join(dynamic_link)
|
.join(dynamic_link)
|
||||||
.on(contact.name == dynamic_link.parent)
|
.on(type_doctype.name == dynamic_link.parent)
|
||||||
.select(contact.name, contact.email_id)
|
.select(type_doctype.name)
|
||||||
.where(
|
.where(
|
||||||
(dynamic_link.link_name == supplier)
|
(dynamic_link.link_name == supplier)
|
||||||
& (dynamic_link.link_doctype == "Supplier")
|
& (dynamic_link.link_doctype == "Supplier")
|
||||||
& (contact.name.like(f"%{txt}%"))
|
& (type_doctype.name.like(f"%{txt}%"))
|
||||||
)
|
)
|
||||||
).run(as_dict=False)
|
)
|
||||||
|
|
||||||
|
if type == "Contact":
|
||||||
|
query = query.select(type_doctype.email_id)
|
||||||
|
|
||||||
|
return query.run()
|
||||||
|
|||||||
@@ -55,17 +55,20 @@ frappe.ui.form.on("Customer", {
|
|||||||
|
|
||||||
frm.set_query("customer_primary_contact", function (doc) {
|
frm.set_query("customer_primary_contact", function (doc) {
|
||||||
return {
|
return {
|
||||||
query: "erpnext.selling.doctype.customer.customer.get_customer_primary_contact",
|
query: "erpnext.selling.doctype.customer.customer.get_customer_primary",
|
||||||
filters: {
|
filters: {
|
||||||
customer: doc.name,
|
customer: doc.name,
|
||||||
|
type: "Contact",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
frm.set_query("customer_primary_address", function (doc) {
|
frm.set_query("customer_primary_address", function (doc) {
|
||||||
return {
|
return {
|
||||||
|
query: "erpnext.selling.doctype.customer.customer.get_customer_primary",
|
||||||
filters: {
|
filters: {
|
||||||
link_doctype: "Customer",
|
customer: doc.name,
|
||||||
link_name: doc.name,
|
type: "Address",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -610,7 +610,11 @@
|
|||||||
"link_fieldname": "party"
|
"link_fieldname": "party"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
<<<<<<< HEAD
|
||||||
"modified": "2025-03-05 10:01:47.885574",
|
"modified": "2025-03-05 10:01:47.885574",
|
||||||
|
=======
|
||||||
|
"modified": "2025-11-25 09:35:56.772949",
|
||||||
|
>>>>>>> c2b8b97d7d (fix: incorrect query filter when selecting primary customer adr (#50727))
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Selling",
|
"module": "Selling",
|
||||||
"name": "Customer",
|
"name": "Customer",
|
||||||
|
|||||||
@@ -800,21 +800,29 @@ def make_address(args, is_primary_address=1, is_shipping_address=1):
|
|||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
@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(doctype, txt, searchfield, start, page_len, filters):
|
||||||
customer = filters.get("customer")
|
customer = filters.get("customer")
|
||||||
|
type = filters.get("type")
|
||||||
con = qb.DocType("Contact")
|
type_doctype = qb.DocType(type)
|
||||||
dlink = qb.DocType("Dynamic Link")
|
dlink = qb.DocType("Dynamic Link")
|
||||||
|
|
||||||
return (
|
query = (
|
||||||
qb.from_(con)
|
qb.from_(type_doctype)
|
||||||
.join(dlink)
|
.join(dlink)
|
||||||
.on(con.name == dlink.parent)
|
.on(type_doctype.name == dlink.parent)
|
||||||
.select(con.name, con.email_id)
|
.select(type_doctype.name)
|
||||||
.where((dlink.link_name == customer) & (con.name.like(f"%{txt}%")))
|
.where(
|
||||||
.run()
|
(dlink.link_name == customer)
|
||||||
|
& (type_doctype.name.like(f"%{txt}%"))
|
||||||
|
& (dlink.link_doctype == "Customer")
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if type == "Contact":
|
||||||
|
query = query.select(type_doctype.email_id)
|
||||||
|
|
||||||
|
return query.run()
|
||||||
|
|
||||||
|
|
||||||
def parse_full_name(full_name: str) -> tuple[str, str | None, str | None]:
|
def parse_full_name(full_name: str) -> tuple[str, str | None, str | None]:
|
||||||
"""Parse full name into first name, middle name and last name"""
|
"""Parse full name into first name, middle name and last name"""
|
||||||
|
|||||||
Reference in New Issue
Block a user