diff --git a/erpnext/public/js/templates/address_list.html b/erpnext/public/js/templates/address_list.html new file mode 100644 index 0000000000..e85723fe89 --- /dev/null +++ b/erpnext/public/js/templates/address_list.html @@ -0,0 +1,20 @@ +
+{% for(var i=0, l=addr_list.length; i{%= i+1 %}. {%= addr_list[i].address_type %}
+{%= addr_list[i].display %}
+{%= __("No address added yet.") %}
+{% } %} diff --git a/erpnext/public/js/templates/contact_list.html b/erpnext/public/js/templates/contact_list.html new file mode 100644 index 0000000000..ac192eaa0a --- /dev/null +++ b/erpnext/public/js/templates/contact_list.html @@ -0,0 +1,18 @@ + +{% for(var i=0, l=contact_list.length; i{%= i+1 %}. {%= contact_list[i].first_name %} {%= contact_list[i].last_name %}
+{%= __("Phone") %}: {%= contact_list[i].phone %}
+{%= __("No contacts added yet.") %}
+{% } %} diff --git a/erpnext/utilities/address_and_contact.py b/erpnext/utilities/address_and_contact.py new file mode 100644 index 0000000000..382c98c3e6 --- /dev/null +++ b/erpnext/utilities/address_and_contact.py @@ -0,0 +1,19 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import frappe + +def load_address_and_contact(doc, key): + """Loads address list and contact list in `__onload`""" + from erpnext.utilities.doctype.address.address import get_address_display + + doc.get("__onload").addr_list = [a.update({"display": get_address_display(a)}) \ + for a in frappe.get_all("Address", + fields="*", filters={key: doc.name}, + order_by="is_primary_address desc, modified desc")] + + if doc.doctype != "Lead": + doc.get("__onload").contact_list = frappe.get_all("Contact", + fields="*", filters={key: doc.name}, + order_by="is_primary_contact desc, modified desc")