[refactor] address and contact list in customer, supplier, lead, sales person
This commit is contained in:
parent
7d36875d6f
commit
5eeef7f065
20
erpnext/public/js/templates/address_list.html
Normal file
20
erpnext/public/js/templates/address_list.html
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<p><button class="btn btn-sm btn-default btn-address">
|
||||||
|
<i class="icon-plus"></i> New Address</button></p>
|
||||||
|
{% for(var i=0, l=addr_list.length; i<l; i++) { %}
|
||||||
|
<hr>
|
||||||
|
<a href="#Form/Address/{%= addr_list[i].name %}" class="btn btn-sm btn-default pull-right">
|
||||||
|
{%= __("Edit") %}</a>
|
||||||
|
<p><b>{%= i+1 %}. {%= addr_list[i].address_type %}</b></p>
|
||||||
|
<div style="padding-left: 15px;">
|
||||||
|
<div>
|
||||||
|
{% if(addr_list[i].is_primary_address) { %}<span class="label label-info">
|
||||||
|
{%= __("Primary") %}</span>{% } %}
|
||||||
|
{% if(addr_list[i].is_shipping_address) { %}<span class="label label-default">
|
||||||
|
{%= __("Shipping") %}</span>{% } %}
|
||||||
|
</div>
|
||||||
|
<p style="margin-top: 5px;">{%= addr_list[i].display %}</p>
|
||||||
|
</div>
|
||||||
|
{% } %}
|
||||||
|
{% if(!addr_list.length) { %}
|
||||||
|
<p class="text-muted">{%= __("No address added yet.") %}</p>
|
||||||
|
{% } %}
|
18
erpnext/public/js/templates/contact_list.html
Normal file
18
erpnext/public/js/templates/contact_list.html
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<p><button class="btn btn-sm btn-default btn-contact">
|
||||||
|
<i class="icon-plus"></i> New Contact</button></p>
|
||||||
|
{% for(var i=0, l=contact_list.length; i<l; i++) { %}
|
||||||
|
<hr>
|
||||||
|
<a href="#Form/Contact/{%= contact_list[i].name %}" class="btn btn-sm btn-default pull-right">
|
||||||
|
{%= __("Edit") %}</a>
|
||||||
|
<p><b>{%= i+1 %}. {%= contact_list[i].first_name %} {%= contact_list[i].last_name %}</b></p>
|
||||||
|
<div style="padding-left: 15px;">
|
||||||
|
<div>
|
||||||
|
{% if(contact_list[i].is_primary_contact) { %}<span class="label label-info">
|
||||||
|
{%= __("Primary") %}</span>{% } %}
|
||||||
|
</div>
|
||||||
|
<p style="padding-top: 5px;">{%= __("Phone") %}: {%= contact_list[i].phone %}</p>
|
||||||
|
</div>
|
||||||
|
{% } %}
|
||||||
|
{% if(!contact_list.length) { %}
|
||||||
|
<p class="text-muted">{%= __("No contacts added yet.") %}</p>
|
||||||
|
{% } %}
|
19
erpnext/utilities/address_and_contact.py
Normal file
19
erpnext/utilities/address_and_contact.py
Normal file
@ -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")
|
Loading…
x
Reference in New Issue
Block a user