AttributeError: 'MariaDBDatabase' object has no attribute 'delete_doc_if_exists'

Hello,

I’m having this error when trying to cancel a Patient Encounter:

image

I’ve already run a bench update,

The version is: ERPNext: v13.0.0-beta.3 (version-13-beta)
Frappe Framework: v13.0.0-beta.3 (version-13-beta)

And the traceback is:

Traceback (most recent call last):
  File "/home/informemedico/erpnext/erpnext/apps/frappe/frappe/app.py", line 64, in application
    response = frappe.api.handle()
  File "/home/informemedico/erpnext/erpnext/apps/frappe/frappe/api.py", line 58, in handle
    return frappe.handler.handle()
  File "/home/informemedico/erpnext/erpnext/apps/frappe/frappe/handler.py", line 30, in handle
    data = execute_cmd(cmd)
  File "/home/informemedico/erpnext/erpnext/apps/frappe/frappe/handler.py", line 69, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
  File "/home/informemedico/erpnext/erpnext/apps/frappe/frappe/__init__.py", line 1085, in call
    return fn(*args, **newargs)
  File "/home/informemedico/erpnext/erpnext/apps/frappe/frappe/desk/form/save.py", line 42, in cancel
    doc.cancel()
  File "/home/informemedico/erpnext/erpnext/apps/frappe/frappe/model/document.py", line 890, in cancel
    self._cancel()
  File "/home/informemedico/erpnext/erpnext/apps/frappe/frappe/model/document.py", line 880, in _cancel
    self.save()
  File "/home/informemedico/erpnext/erpnext/apps/frappe/frappe/model/document.py", line 281, in save
    return self._save(*args, **kwargs)
  File "/home/informemedico/erpnext/erpnext/apps/frappe/frappe/model/document.py", line 333, in _save
    self.run_post_save_methods()
  File "/home/informemedico/erpnext/erpnext/apps/frappe/frappe/model/document.py", line 953, in run_post_save_methods
    self.run_method("on_cancel")
  File "/home/informemedico/erpnext/erpnext/apps/frappe/frappe/model/document.py", line 815, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "/home/informemedico/erpnext/erpnext/apps/frappe/frappe/model/document.py", line 1107, in composer
    return composed(self, method, *args, **kwargs)
  File "/home/informemedico/erpnext/erpnext/apps/frappe/frappe/model/document.py", line 1090, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "/home/informemedico/erpnext/erpnext/apps/frappe/frappe/model/document.py", line 809, in <lambda>
    fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
  File "/home/informemedico/erpnext/erpnext/apps/erpnext/erpnext/healthcare/doctype/patient_encounter/patient_encounter.py", line 30, in on_cancel
    delete_medical_record(self)
  File "/home/informemedico/erpnext/erpnext/apps/erpnext/erpnext/healthcare/doctype/patient_encounter/patient_encounter.py", line 76, in delete_medical_record
    frappe.db.delete_doc_if_exists('Patient Medical Record', 'reference_name', encounter.name)
  File "/home/informemedico/erpnext/erpnext/env/lib/python3.6/site-packages/werkzeug/local.py", line 348, in __getattr__
    return getattr(self._get_current_object(), name)
AttributeError: 'MariaDBDatabase' object has no attribute 'delete_doc_if_exists'

Thanks for reporting!

fixed in the PR: fix: attribute error while cancelling patient encounter by ruchamahabal · Pull Request #22625 · frappe/erpnext · GitHub

2 Likes

Im getting same error!

Installed Apps

ERPNext: v12.14.0 (version-12)

Frappe Framework: v12.12.0 (version-12)

Hello! This was fixed on later releases. Try updating your ERPNext version, that worked for me!