estimate
This commit is contained in:
parent
afa161a0cf
commit
c35689aaf8
@ -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"),
|
||||
|
||||
21
custom_ui/events/estimate.py
Normal file
21
custom_ui/events/estimate.py
Normal 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")
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user