diff --git a/erpnext/selling/doctype/quotation/quotation.py b/erpnext/selling/doctype/quotation/quotation.py index 524a7a6039b..dabb12bca42 100644 --- a/erpnext/selling/doctype/quotation/quotation.py +++ b/erpnext/selling/doctype/quotation/quotation.py @@ -205,8 +205,8 @@ def _make_sales_invoice(source_name, target_doc=None, ignore_permissions=False): def _make_customer(source_name, ignore_permissions=False): quotation = frappe.db.get_value("Quotation", source_name, ["order_type", "customer_lead"]) - if quotation and quotation[0] and not quotation[2]: - lead_name = quotation[0] + if quotation and quotation[1]: + lead_name = quotation[1] customer_name = frappe.db.get_value("Customer", {"lead_name": lead_name}, ["name", "customer_name"], as_dict=True) if not customer_name: diff --git a/erpnext/shopping_cart/cart.py b/erpnext/shopping_cart/cart.py index cc3205c7d70..691b960d05a 100644 --- a/erpnext/shopping_cart/cart.py +++ b/erpnext/shopping_cart/cart.py @@ -192,7 +192,7 @@ def _get_cart_quotation(party=None): party = get_party() quotation = frappe.get_all("Quotation", fields=["name"], filters= - {party.doctype.lower(): party.name, "order_type": "Shopping Cart", "docstatus": 0}, + {"customer_lead": party.name, "order_type": "Shopping Cart", "docstatus": 0}, order_by="modified desc", limit_page_length=1) if quotation: