Error while deleteting any data

Traceback (most recent call last):
  File "/home/vhrs/frappe-bench/apps/frappe/frappe/app.py", line 55, in application
    response = frappe.handler.handle()
  File "/home/vhrs/frappe-bench/apps/frappe/frappe/handler.py", line 19, in handle
    execute_cmd(cmd)
  File "/home/vhrs/frappe-bench/apps/frappe/frappe/handler.py", line 36, in execute_cmd
    ret = frappe.call(method, **frappe.form_dict)
  File "/home/vhrs/frappe-bench/apps/frappe/frappe/__init__.py", line 854, in call
    return fn(*args, **newargs)
  File "/home/vhrs/frappe-bench/apps/frappe/frappe/desk/reportview.py", line 134, in delete_items
    frappe.delete_doc(doctype, d)
  File "/home/vhrs/frappe-bench/apps/frappe/frappe/__init__.py", line 591, in delete_doc
    ignore_permissions, flags)
  File "/home/vhrs/frappe-bench/apps/frappe/frappe/model/delete_doc.py", line 72, in delete_doc
    doc.run_method("on_trash")
  File "/home/vhrs/frappe-bench/apps/frappe/frappe/model/document.py", line 601, in run_method
    return Document.hook(fn)(self, *args, **kwargs)
  File "/home/vhrs/frappe-bench/apps/frappe/frappe/model/document.py", line 765, in composer
    return composed(self, method, *args, **kwargs)
  File "/home/vhrs/frappe-bench/apps/frappe/frappe/model/document.py", line 748, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "/home/vhrs/frappe-bench/apps/frappe/frappe/model/document.py", line 595, in 
    fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
  File "/home/vhrs/frappe-bench/apps/erpnext/erpnext/setup/doctype/company/company.py", line 198, in on_trash
    where exists(select name from tabBudget where name=b.parent and company = %s)""", self.name)
  File "/home/vhrs/frappe-bench/apps/frappe/frappe/database.py", line 136, in sql
    self._cursor.execute(query, values)
  File "/home/vhrs/frappe-bench/env/local/lib/python2.7/site-packages/MySQLdb/cursors.py", line 205, in execute
    self.errorhandler(self, exc, value)
  File "/home/vhrs/frappe-bench/env/local/lib/python2.7/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
    raise errorclass, errorvalue
ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'b\n\t\t\t\twhere exists(select name from tabBudget where name=b.parent and company = ' at line 1")

@nabinhait seems related to budget

I never tried related to budget but it is throwing error

Pushed the fix, please update and check.