From 993244a72e56a671cdc512631b6460b41a5f615d Mon Sep 17 00:00:00 2001 From: Casey Date: Mon, 23 Feb 2026 13:15:11 -0600 Subject: [PATCH] estimate manual accept --- custom_ui/api/db/estimates.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/custom_ui/api/db/estimates.py b/custom_ui/api/db/estimates.py index 5b54659..d43d1eb 100644 --- a/custom_ui/api/db/estimates.py +++ b/custom_ui/api/db/estimates.py @@ -316,11 +316,19 @@ def manual_response(name, response): accepted = True if response == "Accepted" else False new_status = "Estimate Accepted" if accepted else "Lost" + # If the estimate hasn't been submitted yet, submit it first + # so that on_update_after_submit hooks fire (Lead conversion, SO/Project creation, etc.) + if estimate.docstatus == 0: + print("DEBUG: Estimate not yet submitted, submitting now before setting response.") + estimate.flags.ignore_permissions = True + estimate.submit() + estimate.custom_response = response estimate.custom_current_status = new_status estimate.flags.ignore_permissions = True print("DEBUG: Updating estimate with response:", response, "and status:", new_status) estimate.save() + frappe.db.commit() return build_success_response(estimate.as_dict()) except Exception as e: return build_error_response(str(e), 500)