update bugs
This commit is contained in:
parent
520e239741
commit
fe46f18d60
6 changed files with 198 additions and 203 deletions
|
|
@ -253,17 +253,25 @@ def upsert_client(data):
|
|||
print("#####DEBUG: Processing contact data:", contact_data)
|
||||
contact_exists = frappe.db.exists("Contact", {"email_id": contact_data.get("email"), "phone": contact_data.get("phone_number")})
|
||||
if not contact_exists:
|
||||
is_primary_contact = 1 if contact_data.get("is_primary_contact") else 0
|
||||
contact_doc = frappe.get_doc({
|
||||
"doctype": "Contact",
|
||||
"first_name": contact_data.get("first_name"),
|
||||
"last_name": contact_data.get("last_name"),
|
||||
"email_id": contact_data.get("email"),
|
||||
"phone": contact_data.get("phone_number"),
|
||||
# "email_id": contact_data.get("email"),
|
||||
# "phone": contact_data.get("phone_number"),
|
||||
"custom_customer": customer_doc.name,
|
||||
"role": contact_data.get("contact_role", "Other"),
|
||||
"custom_email": contact_data.get("email"),
|
||||
"is_primary_contact": is_primary_contact
|
||||
"is_primary_contact": data.get("is_primary", False),
|
||||
"email_ids": [{
|
||||
"email_id": contact_data.get("email"),
|
||||
"is_primary": 1
|
||||
}],
|
||||
"phone_nos": [{
|
||||
"phone": contact_data.get("phone_number"),
|
||||
"is_primary_mobile_no": 1,
|
||||
"is_primary_phone": 1
|
||||
}]
|
||||
}).insert(ignore_permissions=True)
|
||||
print("Created new contact:", contact_doc.as_dict())
|
||||
else:
|
||||
|
|
@ -316,6 +324,7 @@ def upsert_client(data):
|
|||
# Contact -> Customer & Address
|
||||
print("#####DEBUG: Linking contacts to customer.")
|
||||
for contact_doc in contact_docs:
|
||||
contact_doc.address = address_doc.name
|
||||
contact_doc.append("links", {
|
||||
"link_doctype": "Customer",
|
||||
"link_name": customer_doc.name
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue