Sfoglia il codice sorgente

Allow the creation of an organization lead (#4534)

version-14
Charles-Henri Decultot 7 anni fa
committed by Rushabh Mehta
parent
commit
4c42ff2296
2 ha cambiato i file con 17 aggiunte e 13 eliminazioni
  1. +12
    -13
      frappe/contacts/address_and_contact.py
  2. +5
    -0
      frappe/contacts/doctype/contact/contact.py

+ 12
- 13
frappe/contacts/address_and_contact.py Vedi File

@@ -26,18 +26,17 @@ def load_address_and_contact(doc, key=None):
doc.set_onload('addr_list', address_list) doc.set_onload('addr_list', address_list)


contact_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) 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) order_by="dt asc", as_list=True)


all_doctypes = doctypes + _doctypes all_doctypes = doctypes + _doctypes
return sorted(all_doctypes, key=lambda item: item[0])
return sorted(all_doctypes, key=lambda item: item[0])

+ 5
- 0
frappe/contacts/doctype/contact/contact.py Vedi File

@@ -46,6 +46,11 @@ class Contact(Document):


return None 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): def has_common_link(self, doc):
reference_links = [(link.link_doctype, link.link_name) for link in doc.links] reference_links = [(link.link_doctype, link.link_name) for link in doc.links]
for link in self.links: for link in self.links:


Caricamento…
Annulla
Salva