blob: 382c98c3e623b16a2caccd32dbdbcb75214de993 [file] [log] [blame]
Rushabh Mehta5eeef7f2014-11-24 14:16:51 +05301# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
2# License: GNU General Public License v3. See license.txt
3
4from __future__ import unicode_literals
5import frappe
6
7def load_address_and_contact(doc, key):
8 """Loads address list and contact list in `__onload`"""
9 from erpnext.utilities.doctype.address.address import get_address_display
10
11 doc.get("__onload").addr_list = [a.update({"display": get_address_display(a)}) \
12 for a in frappe.get_all("Address",
13 fields="*", filters={key: doc.name},
14 order_by="is_primary_address desc, modified desc")]
15
16 if doc.doctype != "Lead":
17 doc.get("__onload").contact_list = frappe.get_all("Contact",
18 fields="*", filters={key: doc.name},
19 order_by="is_primary_contact desc, modified desc")