Fix portal orders: remove nonexistent custom_contact_email field query
The custom_contact_email field doesn't exist on Sales Order DocType, causing the email-based fallback query to crash. Simplified to use Customer record lookup only (email_id match works). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
924b9e792b
commit
19be48231d
1 changed files with 3 additions and 17 deletions
|
|
@ -97,6 +97,7 @@ def get_context(context):
|
|||
"status",
|
||||
]
|
||||
|
||||
raw_orders = []
|
||||
if customer_name:
|
||||
raw_orders = frappe.get_all(
|
||||
"Sales Order",
|
||||
|
|
@ -105,24 +106,9 @@ def get_context(context):
|
|||
order_by="transaction_date desc",
|
||||
limit=50,
|
||||
)
|
||||
else:
|
||||
raw_orders = []
|
||||
|
||||
# Also fetch orders by contact email (catches orders where Customer
|
||||
# record wasn't linked, e.g. compliance orders placed via PW checkout)
|
||||
email_orders = frappe.get_all(
|
||||
"Sales Order",
|
||||
filters={"custom_contact_email": user_email, "docstatus": ["!=", 2]},
|
||||
fields=so_fields,
|
||||
order_by="transaction_date desc",
|
||||
limit=50,
|
||||
)
|
||||
# Merge without duplicates
|
||||
seen = {so["name"] for so in raw_orders}
|
||||
for so in email_orders:
|
||||
if so["name"] not in seen:
|
||||
raw_orders.append(so)
|
||||
seen.add(so["name"])
|
||||
if not raw_orders:
|
||||
context.message = "No orders found for your account. If you recently placed an order, it may take a few minutes to appear."
|
||||
|
||||
orders = []
|
||||
for so in raw_orders:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue