This commit is contained in:
Casey Wittrock 2025-11-26 17:07:53 -06:00
parent afa161a0cf
commit c35689aaf8
3 changed files with 26 additions and 3 deletions

View File

@ -96,11 +96,10 @@ def upsert_estimate(data):
print("DOIFJSEOFJISLFK")
try:
data = json.loads(data) if isinstance(data, str) else data
print("DEBUG: Upsert estimate data received:", data)
address_name = frappe.get_value("Address", fieldname="name", filters={"full_address": data.get("address")})
print("DEBUG: Retrieved address name:", data.get("address_name"))
new_estimate = frappe.get_doc({
"doctype": "Quotation",
"custom_installation_address": address_name,
"custom_installation_address": data.get("address_name"),
"contact_email": data.get("contact_email"),
"party_name": data.get("contact_name"),
"customer_name": data.get("customer_name"),

View File

@ -0,0 +1,21 @@
import frappe
def after_insert(doc, method):
try:
print("DEBUG: after_insert hook triggered for Quotation:", doc.name)
print("DEBUG: custom_installation_address:", doc.custom_installation_address)
if not doc.custom_installation_address:
print("ERROR: custom_installation_address is empty")
return
address_doc = frappe.get_doc("Address", doc.custom_installation_address)
print("DEBUG: Retrieved address document:", address_doc.name)
address_doc.custom_estimate_sent_status = "In Progress"
address_doc.save()
print("DEBUG: Address status updated successfully")
except Exception as e:
print("ERROR in after_insert hook:", str(e))
frappe.log_error(f"Error in estimate after_insert: {str(e)}", "Estimate Hook Error")

View File

@ -165,6 +165,9 @@ doc_events = {
"Address": {
"after_insert": "custom_ui.events.address.after_insert"
},
"Quotation": {
"after_insert": "custom_ui.events.estimate.after_insert"
}
}
# Scheduled Tasks