diff --git a/erpnext/crm/doctype/appointment/appointment.py b/erpnext/crm/doctype/appointment/appointment.py index 714e88ded38..2b9d31da505 100644 --- a/erpnext/crm/doctype/appointment/appointment.py +++ b/erpnext/crm/doctype/appointment/appointment.py @@ -142,6 +142,8 @@ class Appointment(Document): 'party_name': self.lead, }, order_by='creation desc') + if not opporutnities: + return None latest_opportunity = frappe.get_doc( 'Opportunity', opporutnities[0].name) assignee = latest_opportunity._assign