fix: Duplicate addresses are creating while using the E-commerce
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
|
||||
import frappe
|
||||
import frappe.defaults
|
||||
from frappe import _, throw
|
||||
from frappe import _, bold, throw
|
||||
from frappe.contacts.doctype.address.address import get_address_display
|
||||
from frappe.contacts.doctype.contact.contact import get_contact_name
|
||||
from frappe.utils import cint, cstr, flt, get_fullname
|
||||
@@ -201,6 +201,11 @@ def get_shopping_cart_menu(context=None):
|
||||
@frappe.whitelist()
|
||||
def add_new_address(doc):
|
||||
doc = frappe.parse_json(doc)
|
||||
address_title = doc.get("address_title")
|
||||
if frappe.db.exists("Address", {"address_title": address_title}):
|
||||
msg = f"The address with the title {bold(address_title)} already exists. Please change the title accordingly."
|
||||
frappe.throw(_(msg), title=_("Address Already Exists"))
|
||||
|
||||
doc.update({"doctype": "Address"})
|
||||
address = frappe.get_doc(doc)
|
||||
address.save(ignore_permissions=True)
|
||||
|
||||
Reference in New Issue
Block a user