fix: wrap scheduled_time
with getdate()
(#20044)
* fix: wrap `scheduled_time` with `getdate()` Handles inconsistent data returned from the ORM. * fix: use `getdate()` instead of `date()`
This commit is contained in:
parent
bd5f5dabbd
commit
8bada8759a
@ -11,7 +11,7 @@ from datetime import timedelta
|
|||||||
import frappe
|
import frappe
|
||||||
from frappe import _
|
from frappe import _
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
from frappe.utils import get_url
|
from frappe.utils import get_url, getdate
|
||||||
from frappe.utils.verified_command import verify_request, get_signed_params
|
from frappe.utils.verified_command import verify_request, get_signed_params
|
||||||
|
|
||||||
|
|
||||||
@ -117,7 +117,7 @@ class Appointment(Document):
|
|||||||
if self._assign:
|
if self._assign:
|
||||||
return
|
return
|
||||||
available_agents = _get_agents_sorted_by_asc_workload(
|
available_agents = _get_agents_sorted_by_asc_workload(
|
||||||
self.scheduled_time.date())
|
getdate(self.scheduled_time))
|
||||||
for agent in available_agents:
|
for agent in available_agents:
|
||||||
if(_check_agent_availability(agent, self.scheduled_time)):
|
if(_check_agent_availability(agent, self.scheduled_time)):
|
||||||
agent = agent[0]
|
agent = agent[0]
|
||||||
@ -189,7 +189,7 @@ def _get_agents_sorted_by_asc_workload(date):
|
|||||||
assigned_to = frappe.parse_json(appointment._assign)
|
assigned_to = frappe.parse_json(appointment._assign)
|
||||||
if not assigned_to:
|
if not assigned_to:
|
||||||
continue
|
continue
|
||||||
if (assigned_to[0] in agent_list) and appointment.scheduled_time.date() == date:
|
if (assigned_to[0] in agent_list) and getdate(appointment.scheduled_time) == date:
|
||||||
appointment_counter[assigned_to[0]] += 1
|
appointment_counter[assigned_to[0]] += 1
|
||||||
sorted_agent_list = appointment_counter.most_common()
|
sorted_agent_list = appointment_counter.most_common()
|
||||||
sorted_agent_list.reverse()
|
sorted_agent_list.reverse()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user