fix: not able to make sales order from the lead quotation

This commit is contained in:
Rohit Waghchaure
2019-05-06 17:16:57 +05:30
parent 2c229c6403
commit ead8d82a84

View File

@@ -212,9 +212,12 @@ def _make_sales_invoice(source_name, target_doc=None, ignore_permissions=False):
return doclist
def _make_customer(source_name, ignore_permissions=False):
quotation = frappe.db.get_value("Quotation", source_name, ["order_type", "party_name", "customer_name"])
if quotation and quotation[1] and not quotation[2]:
lead_name = quotation[1]
quotation = frappe.db.get_value("Quotation",
source_name, ["order_type", "party_name", "customer_name"], as_dict=1)
if quotation and quotation.get('party_name'):
if not frappe.db.exists("Customer", quotation.get("party_name")):
lead_name = quotation.get("party_name")
customer_name = frappe.db.get_value("Customer", {"lead_name": lead_name},
["name", "customer_name"], as_dict=True)
if not customer_name:
@@ -222,7 +225,7 @@ def _make_customer(source_name, ignore_permissions=False):
customer_doclist = _make_customer(lead_name, ignore_permissions=ignore_permissions)
customer = frappe.get_doc(customer_doclist)
customer.flags.ignore_permissions = ignore_permissions
if quotation[1] == "Shopping Cart":
if quotation.get("party_name") == "Shopping Cart":
customer.customer_group = frappe.db.get_value("Shopping Cart Settings", None,
"default_customer_group")
@@ -242,5 +245,5 @@ def _make_customer(source_name, ignore_permissions=False):
frappe.throw(_("Please create Customer from Lead {0}").format(lead_name))
else:
return customer_name
elif quotation and quotation[1]:
return frappe.get_doc("Customer",quotation[1])
else:
return frappe.get_doc("Customer", quotation.get("party_name"))