[fixes] address and contact

This commit is contained in:
Rushabh Mehta
2017-01-14 00:25:22 +05:30
parent c0bfb0ba56
commit 95439db53f
10 changed files with 113 additions and 146 deletions

View File

@@ -31,12 +31,11 @@ def update_website_context(context):
def check_customer_or_supplier():
if frappe.session.user:
contacts = frappe.get_all("Contact", fields=["customer", "supplier", "email_id"],
filters={"email_id": frappe.session.user})
contact_name = frappe.get_value("Contact", {"email_id": frappe.session.user})
if contact_name:
contact = frappe.get_doc('Contact', contact_name)
for link in contact.links:
if link.link_doctype in ('Customer', 'Supplier'):
return link.link_doctype, link.link_name
customer = [d.customer for d in contacts if d.customer] or None
supplier = [d.supplier for d in contacts if d.supplier] or None
if customer: return 'Customer', customer
if supplier : return 'Supplier', supplier
return 'Customer', None