[fix] address creation for new user

This commit is contained in:
Anand Doshi
2015-12-08 12:34:01 +05:30
parent 441b2c7657
commit cc24d28ddc
4 changed files with 27 additions and 8 deletions

View File

@@ -280,6 +280,7 @@ def get_customer(user=None):
user = frappe.session.user
customer = frappe.db.get_value("Contact", {"email_id": user}, "customer")
if customer:
return frappe.get_doc("Customer", customer)
@@ -320,6 +321,17 @@ def get_address_docs(doctype=None, txt=None, filters=None, limit_start=0, limit_
return address_docs
def set_customer_in_address(doc, method=None):
if doc.flags.linked:
return
doc.check_if_linked()
if not doc.flags.linked and (frappe.db.get_value("User", frappe.session.user, "user_type") == "Website User"):
# creates a customer if one does not exist
get_customer()
doc.link_address()
@frappe.whitelist()
def apply_shipping_rule(shipping_rule):
quotation = _get_cart_quotation()