Error: expected string, got datetime during Sales Invoice submit from Patient Appointment

Hi everyone,

I’m facing an issue while booking a Patient Appointment which internally creates a Sales Invoice.


App Versions

{
  "assessment_templates": "1.0.0",
  "erpnext": "15.67.0",
  "frappe": "15.92.0",
  "frappe_themes": "0.0.1",
  "frappe_whatsapp": "1.0.7",
  "healthcare": "15.1.3",
  "hrms": "15.47.5",
  "india_compliance": "15.19.3",
  "insights": "3.2.9",
  "payments": "0.0.1",
  "print_designer": "1.5.2"
}

API Endpoint

/api/method/healthcare.healthcare.doctype.patient.patient.book_appointment

Error

TypeError: expected string or bytes-like object, got 'datetime.datetime'

Traceback (Relevant Part)

File "apps/frappe/frappe/utils/formatters.py", line 102, in format_value
    if not BLOCK_TAGS_PATTERN.search(value):
TypeError: expected string or bytes-like object, got 'datetime.datetime'

What is happening

  • While booking an appointment, system calls:

    • book_appointment

    • invoice_appointment

    • create_sales_invoice

    • si.submit()

  • During Sales Invoice submit, Frappe tries to create a Version record

  • While computing diff (get_diff), it tries to format a field

  • That field contains a datetime object instead of string, causing failure in format_value


Request Payload

{
  "patient": "HLC-PAT-2026-00020",
  "appointment_book": {
    "appointment_date": "2026-05-05",
    "appointment_time": "12:24:12",
    "reference_date": "2026-05-05",
    "consulting_amount": 370,
    "mode_of_payment": "Cash"
  }
}

My Observation

It looks like:

  • A field (possibly in Sales Invoice or child table) is storing a datetime.datetime object

  • But during version comparison, Frappe expects a string for formatting


Questions

  1. Is this a known issue in Frappe v15 Versioning?

  2. Should datetime fields be manually converted before submit?

  3. Is there any recommended fix or patch for this?