fix address map
This commit is contained in:
parent
3c75ba975e
commit
73f4b3b97a
4 changed files with 20 additions and 26 deletions
|
|
@ -109,13 +109,8 @@ def get_client(client_name):
|
|||
clientData.update(map_lead_client(clientData))
|
||||
links = []
|
||||
if customer.doctype == "Customer":
|
||||
links = (
|
||||
[{"link_doctype": "Contact", "link_name": row.contact}
|
||||
for row in customer.get("custom_add_contacts", [])]
|
||||
+
|
||||
[{"link_doctype": "Address", "link_name": row.address}
|
||||
for row in customer.get("custom_select_address", [])]
|
||||
)
|
||||
clientData["addresses"] = customer.custom_select_address or []
|
||||
clientData["contacts"] = customer.custom_add_contacts or []
|
||||
|
||||
else:
|
||||
links = frappe.get_all(
|
||||
|
|
@ -130,16 +125,16 @@ def get_client(client_name):
|
|||
"parent as link_name",
|
||||
]
|
||||
)
|
||||
|
||||
print("DEBUG: Retrieved links from lead:", links)
|
||||
for link in links:
|
||||
print("DEBUG: Processing link:", link)
|
||||
linked_doc = frappe.get_doc(link["link_doctype"], link["link_name"])
|
||||
if link["link_doctype"] == "Contact":
|
||||
clientData["contacts"].append(linked_doc.as_dict())
|
||||
elif link["link_doctype"] == "Address":
|
||||
clientData["addresses"].append(linked_doc.as_dict())
|
||||
print("DEBUG: Retrieved links from lead:", links)
|
||||
for link in links:
|
||||
print("DEBUG: Processing link:", link)
|
||||
linked_doc = frappe.get_doc(link["link_doctype"], link["link_name"])
|
||||
if link["link_doctype"] == "Contact":
|
||||
clientData["contacts"].append(linked_doc.as_dict())
|
||||
elif link["link_doctype"] == "Address":
|
||||
clientData["addresses"].append(linked_doc.as_dict())
|
||||
# TODO: Continue getting other linked docs like jobs, invoices, etc.
|
||||
print("DEBUG: Final client data prepared:", clientData)
|
||||
return build_success_response(clientData)
|
||||
except frappe.ValidationError as ve:
|
||||
return build_error_response(str(ve), 400)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue