From f36bdaadae92d0bffe870f190efe005c39ac187e Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Fri, 8 May 2026 12:55:38 +0000 Subject: [PATCH] fix(crm): handle empty _assign in appointment auto assignment (backport #54782) (#54795) fix(crm): handle empty _assign in appointment auto assignment (#54782) (cherry picked from commit a4a389bd4193f8122fc896c46119abb7a504b794) Co-authored-by: Sakthivel Murugan S <129778327+ssakthivelmurugan@users.noreply.github.com> --- erpnext/crm/doctype/appointment/appointment.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/erpnext/crm/doctype/appointment/appointment.py b/erpnext/crm/doctype/appointment/appointment.py index 9a213aea5fc..0f7c52688a3 100644 --- a/erpnext/crm/doctype/appointment/appointment.py +++ b/erpnext/crm/doctype/appointment/appointment.py @@ -235,10 +235,13 @@ def _get_agents_sorted_by_asc_workload(date): return agent_list appointment_counter = Counter(agent_list) for appointment in appointments: - assigned_to = frappe.parse_json(appointment._assign) - if not assigned_to: + assign_data = appointment._assign + if isinstance(assign_data, str): + assign_data = assign_data.strip() + if not assign_data: continue - if (assigned_to[0] in agent_list) and getdate(appointment.scheduled_time) == date: + assigned_to = frappe.parse_json(assign_data) + if assigned_to and (assigned_to[0] in agent_list) and getdate(appointment.scheduled_time) == date: appointment_counter[assigned_to[0]] += 1 sorted_agent_list = appointment_counter.most_common() sorted_agent_list.reverse()