[fix] Removed customer, supplier and added link_name from website_list_for_contact file

This commit is contained in:
Rohit Waghchaure
2017-03-14 13:26:10 +05:30
parent 27e86201fc
commit 11fa7a9311
3 changed files with 13 additions and 6 deletions

View File

@@ -100,11 +100,12 @@ def post_process(doctype, data):
def get_customers_suppliers(doctype, user):
meta = frappe.get_meta(doctype)
contacts = frappe.get_all("Contact", fields=["customer", "supplier", "email_id"],
filters={"email_id": user})
contacts = frappe.db.sql(""" select `tabContact`.email_id, `tabDynamic Link`.link_doctype, `tabDynamic Link`.link_name
from `tabContact`, `tabDynamic Link` where
`tabContact`.name = `tabDynamic Link`.parent and `tabContact`.email_id =%s """, user, as_dict=1)
customers = [c.customer for c in contacts if c.customer] if meta.get_field("customer") else None
suppliers = [c.supplier for c in contacts if c.supplier] if meta.get_field("supplier") else None
customers = [c.link_name for c in contacts if c.link_doctype == 'Customer'] if meta.get_field("customer") else None
suppliers = [c.link_name for c in contacts if c.link_doctype == 'Supplier'] if meta.get_field("supplier") else None
return customers, suppliers