chore: code improvements

This commit is contained in:
Shivam Mishra 2019-05-07 15:24:59 +05:30
parent 8aa0b5103d
commit a9bf40b7db
2 changed files with 8 additions and 16 deletions

View file

@ -57,14 +57,10 @@ class Address(Document):
def set_link_title(self):
if not self.links:
return
else:
for address in self.links:
if not address.link_title:
linked_doc = frappe.get_doc(address.link_doctype, address.link_name)
try:
address.link_title = linked_doc.title_field
except AttributeError:
address.link_title = linked_doc.name
for address in self.links:
if not address.link_title:
linked_doc = frappe.get_doc(address.link_doctype, address.link_name)
address.link_title = linked_doc.get("title_field") or linked_doc.get("name")
def validate_reference(self):
if self.is_your_company_address:

View file

@ -44,14 +44,10 @@ class Contact(Document):
def set_link_title(self):
if not self.links:
return
else:
for contact in self.links:
if not contact.link_title:
linked_doc = frappe.get_doc(contact.link_doctype, contact.link_name)
try:
contact.link_title = linked_doc.title_field
except AttributeError:
contact.link_title = linked_doc.name
for contact in self.links:
if not contact.link_title:
linked_doc = frappe.get_doc(contact.link_doctype, contact.link_name)
contact.link_title = linked_doc.get("title_field") or linked_doc.get("name")
def get_link_for(self, link_doctype):
'''Return the link name, if exists for the given link DocType'''