diff --git a/erpnext/hooks.py b/erpnext/hooks.py index d20e20b36f6..15f01ca0e6f 100644 --- a/erpnext/hooks.py +++ b/erpnext/hooks.py @@ -81,6 +81,13 @@ website_route_rules = [ "parents": [{"title": _("Request for Quotation"), "name": "rfq"}] } }, + {"from_route": "/addresses", "to_route": "Address"}, + {"from_route": "/addresses/", "to_route": "addresses", + "defaults": { + "doctype": "Address", + "parents": [{"title": _("Addresses"), "name": "addresses"}] + } + }, {"from_route": "/jobs", "to_route": "Job Opening"}, ] diff --git a/erpnext/templates/includes/address_row.html b/erpnext/templates/includes/address_row.html index 15dcb951967..2c5056a2ba1 100644 --- a/erpnext/templates/includes/address_row.html +++ b/erpnext/templates/includes/address_row.html @@ -1,8 +1,14 @@
-

{{ doc.address_title }}

-

- {{ frappe.get_doc(doc).get_display() }} -

+
+
+ {{ doc.address_title }} +
+
{{ doc.address_type }}
+
{{ doc.city }}
+
+ {{ frappe.get_doc(doc).get_display() }} +
+
diff --git a/erpnext/utilities/doctype/address/address.py b/erpnext/utilities/doctype/address/address.py index f613faa67d7..1d215cc0e7a 100644 --- a/erpnext/utilities/doctype/address/address.py +++ b/erpnext/utilities/doctype/address/address.py @@ -9,6 +9,7 @@ from frappe.utils import cstr from frappe.model.document import Document from jinja2 import TemplateSyntaxError +from frappe.utils.user import is_website_user class Address(Document): def __setup__(self): @@ -123,11 +124,22 @@ def get_list_context(context=None): from erpnext.shopping_cart.cart import get_address_docs return { "title": _("Addresses"), - "get_list": get_address_docs, + "get_list": get_address_list, "row_template": "templates/includes/address_row.html", 'no_breadcrumbs': True, } + +def get_address_list(doctype, txt, filters, limit_start, limit_page_length=20): + from frappe.www.list import get_list + user = frappe.session.user + ignore_permissions = False + if is_website_user(): + if not filters: filters = [] + filters.append(("Address", "owner", "=", user)) + ignore_permissions = True + return get_list(doctype, txt, filters, limit_start, limit_page_length, ignore_permissions=ignore_permissions) + def has_website_permission(doc, ptype, user, verbose=False): """Returns true if customer or lead matches with user""" customer = frappe.db.get_value("Contact", {"email_id": frappe.session.user}, "customer")