mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-03 05:28:27 +00:00
* refactor: handle exceptions when updating addresses
* refactor: fold common statements in a loop
(cherry picked from commit 34d2bfbb3e)
Co-authored-by: Shivam Mishra <scmmishra@users.noreply.github.com>
This commit is contained in:
@@ -73,10 +73,16 @@ def link_customer_and_address(raw_billing_data, raw_shipping_data, customer_name
|
|||||||
|
|
||||||
if customer_exists:
|
if customer_exists:
|
||||||
frappe.rename_doc("Customer", old_name, customer_name)
|
frappe.rename_doc("Customer", old_name, customer_name)
|
||||||
billing_address = frappe.get_doc("Address", {"woocommerce_email": customer_woo_com_email, "address_type": "Billing"})
|
for address_type in ("Billing", "Shipping",):
|
||||||
shipping_address = frappe.get_doc("Address", {"woocommerce_email": customer_woo_com_email, "address_type": "Shipping"})
|
try:
|
||||||
rename_address(billing_address, customer)
|
address = frappe.get_doc("Address", {"woocommerce_email": customer_woo_com_email, "address_type": address_type})
|
||||||
rename_address(shipping_address, customer)
|
rename_address(address, customer)
|
||||||
|
except (
|
||||||
|
frappe.DoesNotExistError,
|
||||||
|
frappe.DuplicateEntryError,
|
||||||
|
frappe.ValidationError,
|
||||||
|
):
|
||||||
|
pass
|
||||||
else:
|
else:
|
||||||
create_address(raw_billing_data, customer, "Billing")
|
create_address(raw_billing_data, customer, "Billing")
|
||||||
create_address(raw_shipping_data, customer, "Shipping")
|
create_address(raw_shipping_data, customer, "Shipping")
|
||||||
|
|||||||
Reference in New Issue
Block a user