merge main
This commit is contained in:
parent
f7ce3a39d0
commit
4c8e66d155
9 changed files with 349 additions and 206 deletions
|
|
@ -210,6 +210,38 @@ def get_clients_table_data(filters={}, sortings=[], page=1, page_size=10):
|
|||
except Exception as e:
|
||||
return build_error_response(str(e), 500)
|
||||
|
||||
@frappe.whitelist()
|
||||
def update_client_info(client_name, data):
|
||||
"""Update client information for a given client."""
|
||||
try:
|
||||
data = json.loads(data)
|
||||
print("DEBUG: update_client_info called with client_name:", client_name, "and data:", data)
|
||||
client_doc = check_and_get_client_doc(client_name)
|
||||
if not client_doc:
|
||||
return build_error_response(f"Client with name '{client_name}' does not exist.", 404)
|
||||
address_updates = data.get("addresses", [])
|
||||
contact_updates = data.get("contacts", [])
|
||||
customer_updates = data.get("customer", {})
|
||||
# Update addresses
|
||||
if address_updates:
|
||||
for addr_data in address_updates:
|
||||
update_address(addr_data)
|
||||
# Update contacts
|
||||
if contact_updates:
|
||||
for contact_data in contact_updates:
|
||||
update_contact(contact_data)
|
||||
# Update customer/lead
|
||||
if customer_updates:
|
||||
for field, value in customer_updates.items():
|
||||
if hasattr(client_doc, field):
|
||||
setattr(client_doc, field, value)
|
||||
client_doc.save(ignore_permissions=True)
|
||||
frappe.local.message_log = []
|
||||
return get_client(client_name)
|
||||
except frappe.ValidationError as ve:
|
||||
return build_error_response(str(ve), 400)
|
||||
except Exception as e:
|
||||
return build_error_response(str(e), 500)
|
||||
|
||||
@frappe.whitelist()
|
||||
def upsert_client(data):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue