diff --git a/frappe/contacts/address_and_contact.py b/frappe/contacts/address_and_contact.py index f746731754..9ccffab996 100644 --- a/frappe/contacts/address_and_contact.py +++ b/frappe/contacts/address_and_contact.py @@ -26,18 +26,17 @@ def load_address_and_contact(doc, key=None): doc.set_onload('addr_list', address_list) contact_list = [] - if doc.doctype != "Lead": - filters = [ - ["Dynamic Link", "link_doctype", "=", doc.doctype], - ["Dynamic Link", "link_name", "=", doc.name], - ["Dynamic Link", "parenttype", "=", "Contact"], - ] - contact_list = frappe.get_all("Contact", filters=filters, fields=["*"]) - - contact_list = sorted(contact_list, - lambda a, b: - (int(a.is_primary_contact - b.is_primary_contact)) or - (1 if a.modified - b.modified else 0), reverse=True) + filters = [ + ["Dynamic Link", "link_doctype", "=", doc.doctype], + ["Dynamic Link", "link_name", "=", doc.name], + ["Dynamic Link", "parenttype", "=", "Contact"], + ] + contact_list = frappe.get_all("Contact", filters=filters, fields=["*"]) + + contact_list = sorted(contact_list, + lambda a, b: + (int(a.is_primary_contact - b.is_primary_contact)) or + (1 if a.modified - b.modified else 0), reverse=True) doc.set_onload('contact_list', contact_list) @@ -147,4 +146,4 @@ def filter_dynamic_link_doctypes(doctype, txt, searchfield, start, page_len, fil order_by="dt asc", as_list=True) all_doctypes = doctypes + _doctypes - return sorted(all_doctypes, key=lambda item: item[0]) \ No newline at end of file + return sorted(all_doctypes, key=lambda item: item[0]) diff --git a/frappe/contacts/doctype/contact/contact.py b/frappe/contacts/doctype/contact/contact.py index 23027449b1..9be54b4444 100644 --- a/frappe/contacts/doctype/contact/contact.py +++ b/frappe/contacts/doctype/contact/contact.py @@ -46,6 +46,11 @@ class Contact(Document): return None + def has_link(self, doctype, name): + for link in self.links: + if link.link_doctype==doctype and link.link_name== name: + return True + def has_common_link(self, doc): reference_links = [(link.link_doctype, link.link_name) for link in doc.links] for link in self.links: