Install erpnext app: AttributeError: Database instance has no attribute 'has_index'

Hello,

I tried to make new site (site3.dev), and install-app erpnext, then came error like below. Previously, I’ve tried to install erpnext on site2.dev with same issue like below:

The system is Ubuntu 18.04 64 bit, running on VirtualBox. ERPNext version 11 (staging).

Please help!

Thank you :slight_smile:

bench@osboxes:~/erpnext$ bench new-site site3.dev
MySQL root password: 

Installing frappe...
Updating DocTypes for frappe        : [========================================]
Updating country info               : [========================================]
Set Administrator password: 
Re-enter Administrator password: 
*** Scheduler is disabled ***
bench@osboxes:~/erpnext$ bench use site3.dev
bench@osboxes:~/erpnext$ bench --site site3.dev install-app erpnext

Installing erpnext...
Updating DocTypes for erpnext       : [======================                  ]Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/opt/bench/erpnext/apps/frappe/frappe/utils/bench_helper.py", line 97, in <module>
    main()
  File "/opt/bench/erpnext/apps/frappe/frappe/utils/bench_helper.py", line 18, in main
    click.Group(commands=commands)(prog_name='bench')
  File "/opt/bench/erpnext/env/local/lib/python2.7/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/opt/bench/erpnext/env/local/lib/python2.7/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/opt/bench/erpnext/env/local/lib/python2.7/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/opt/bench/erpnext/env/local/lib/python2.7/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/opt/bench/erpnext/env/local/lib/python2.7/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/opt/bench/erpnext/env/local/lib/python2.7/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/opt/bench/erpnext/env/local/lib/python2.7/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/opt/bench/erpnext/apps/frappe/frappe/commands/__init__.py", line 25, in _func
    ret = f(frappe._dict(ctx.obj), *args, **kwargs)
  File "/opt/bench/erpnext/apps/frappe/frappe/commands/site.py", line 165, in install_app
    _install_app(app, verbose=context.verbose)
  File "/opt/bench/erpnext/apps/frappe/frappe/installer.py", line 145, in install_app
    sync_for(name, force=True, sync_everything=True, verbose=verbose, reset_permissions=True)
  File "/opt/bench/erpnext/apps/frappe/frappe/model/sync.py", line 56, in sync_for
    reset_permissions=reset_permissions, for_sync=True)
  File "/opt/bench/erpnext/apps/frappe/frappe/modules/import_file.py", line 65, in import_file_by_path
    ignore_version=ignore_version, reset_permissions=reset_permissions)
  File "/opt/bench/erpnext/apps/frappe/frappe/modules/import_file.py", line 132, in import_doc
    doc.insert()
  File "/opt/bench/erpnext/apps/frappe/frappe/model/document.py", line 249, in insert
    self.run_post_save_methods()
  File "/opt/bench/erpnext/apps/frappe/frappe/model/document.py", line 905, in run_post_save_methods
    self.run_method("on_update")
  File "/opt/bench/erpnext/apps/frappe/frappe/model/document.py", line 772, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "/opt/bench/erpnext/apps/frappe/frappe/model/document.py", line 1048, in composer
    return composed(self, method, *args, **kwargs)
  File "/opt/bench/erpnext/apps/frappe/frappe/model/document.py", line 1031, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "/opt/bench/erpnext/apps/frappe/frappe/model/document.py", line 766, in <lambda>
    fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
  File "/opt/bench/erpnext/apps/frappe/frappe/core/doctype/doctype/doctype.py", line 264, in on_update
    self.run_module_method("on_doctype_update")
  File "/opt/bench/erpnext/apps/frappe/frappe/core/doctype/doctype/doctype.py", line 331, in run_module_method
    getattr(module, method)()
  File "/opt/bench/erpnext/apps/erpnext/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py", line 127, in on_doctype_update
    if not frappe.db.has_index('tabStock Ledger Entry', 'posting_sort_index'):
  File "/opt/bench/erpnext/env/local/lib/python2.7/site-packages/werkzeug/local.py", line 347, in __getattr__
    return getattr(self._get_current_object(), name)
AttributeError: Database instance has no attribute 'has_index'