mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-08 15:42:52 +00:00
[fixes] portal, issues, addresses etc
This commit is contained in:
@@ -5,17 +5,18 @@ from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe import throw, _
|
||||
import frappe.defaults
|
||||
from frappe.utils import flt, get_fullname, fmt_money, cstr
|
||||
from frappe.utils import cint, flt, get_fullname, fmt_money, cstr
|
||||
from erpnext.utilities.doctype.address.address import get_address_display
|
||||
from frappe.utils.nestedset import get_root_of
|
||||
|
||||
class WebsitePriceListMissingError(frappe.ValidationError): pass
|
||||
|
||||
def set_cart_count(quotation=None):
|
||||
if not quotation:
|
||||
quotation = _get_cart_quotation()
|
||||
cart_count = cstr(len(quotation.get("items")))
|
||||
frappe.local.cookie_manager.set_cookie("cart_count", cart_count)
|
||||
if cint(frappe.db.get_singles_value("Shopping Cart Settings", "enabled")):
|
||||
if not quotation:
|
||||
quotation = _get_cart_quotation()
|
||||
cart_count = cstr(len(quotation.get("items")))
|
||||
frappe.local.cookie_manager.set_cookie("cart_count", cart_count)
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_cart_quotation(doc=None):
|
||||
@@ -29,7 +30,7 @@ def get_cart_quotation(doc=None):
|
||||
return {
|
||||
"doc": decorate_quotation_doc(doc),
|
||||
"addresses": [{"name": address.name, "display": address.display}
|
||||
for address in get_address_docs(party)],
|
||||
for address in get_address_docs(party=party)],
|
||||
"shipping_rules": get_applicable_shipping_rules(party)
|
||||
}
|
||||
|
||||
@@ -281,12 +282,13 @@ def get_lead_or_customer():
|
||||
|
||||
return lead_doc
|
||||
|
||||
def get_address_docs(party=None):
|
||||
def get_address_docs(doctype, txt, filters, limit_start, limit_page_length=20, party=None):
|
||||
if not party:
|
||||
party = get_lead_or_customer()
|
||||
|
||||
address_docs = frappe.db.sql("""select * from `tabAddress`
|
||||
where `%s`=%s order by name""" % (party.doctype.lower(), "%s"), party.name,
|
||||
where `{0}`=%s order by name limit {1}, {2}""".format(party.doctype.lower(),
|
||||
limit_start, limit_page_length), party.name,
|
||||
as_dict=True, update={"doctype": "Address"})
|
||||
|
||||
for address in address_docs:
|
||||
|
||||
@@ -8,7 +8,7 @@ import frappe
|
||||
from frappe import _, msgprint
|
||||
from frappe.utils import comma_and
|
||||
from frappe.model.document import Document
|
||||
from frappe.utils.nestedset import get_ancestors_of
|
||||
from frappe.utils.nestedset import get_ancestors_of, get_root_of
|
||||
from erpnext.utilities.doctype.address.address import get_territory_from_address
|
||||
|
||||
class ShoppingCartSetupError(frappe.ValidationError): pass
|
||||
@@ -42,7 +42,7 @@ class ShoppingCartSettings(Document):
|
||||
return territory_name_map
|
||||
|
||||
def validate_price_lists(self):
|
||||
territory_name_map = self.validate_overlapping_territories("price_lists", "selling_price_list")
|
||||
self.validate_overlapping_territories("price_lists", "selling_price_list")
|
||||
|
||||
# validate that a Shopping Cart Price List exists for the default territory as a catch all!
|
||||
price_list_for_default_territory = self.get_name_from_territory(self.default_territory, "price_lists",
|
||||
@@ -131,7 +131,8 @@ class ShoppingCartSettings(Document):
|
||||
def get_price_list(self, billing_territory):
|
||||
price_list = self.get_name_from_territory(billing_territory, "price_lists", "selling_price_list")
|
||||
if not (price_list and price_list[0]):
|
||||
price_list = self.get_name_from_territory(self.default_territory, "price_lists", "selling_price_list")
|
||||
price_list = self.get_name_from_territory(self.default_territory or get_root_of("Territory"),
|
||||
"price_lists", "selling_price_list")
|
||||
|
||||
return price_list and price_list[0] or None
|
||||
|
||||
@@ -165,7 +166,7 @@ def is_cart_enabled():
|
||||
return get_shopping_cart_settings().enabled
|
||||
|
||||
def get_default_territory():
|
||||
return get_shopping_cart_settings().default_territory
|
||||
return get_shopping_cart_settings().default_territory or get_root_of("Territory")
|
||||
|
||||
def check_shopping_cart_enabled():
|
||||
if not get_shopping_cart_settings().enabled:
|
||||
|
||||
@@ -6,7 +6,6 @@ from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe import _
|
||||
import frappe.defaults
|
||||
from frappe.utils import cint
|
||||
from erpnext.shopping_cart.doctype.shopping_cart_settings.shopping_cart_settings import is_cart_enabled
|
||||
|
||||
def show_cart_count():
|
||||
@@ -44,6 +43,6 @@ def update_my_account_context(context):
|
||||
{"label": _("Orders"), "url": "orders"},
|
||||
{"label": _("Invoices"), "url": "invoices"},
|
||||
{"label": _("Shipments"), "url": "shipments"},
|
||||
# {"label": _("Issues"), "url": "tickets"},
|
||||
{"label": _("Issues"), "url": "issues"},
|
||||
{"label": _("Addresses"), "url": "addresses"},
|
||||
])
|
||||
|
||||
Reference in New Issue
Block a user