Error when Installation HRMS in v14

Hello Frappe family, thank you for your attention this topic in advance.

When I was installing HRMS, an error occurred, I do not know how to fix it, help!

frappe@VM-20-6-ubuntu:~/frappe-bench$ bench install-app hrms
App payments already installed
App erpnext already installed

Installing hrms...
An error occurred while installing hrms: ('Module Def', 'HR', IntegrityError(1062, "Duplicate entry 'HR' for key 'PRIMARY'"))
Traceback (most recent call last):
  File "apps/frappe/frappe/model/base_document.py", line 499, in db_insert
    frappe.db.sql(
  File "apps/frappe/frappe/database/database.py", line 206, in sql
    self._cursor.execute(query, values)
  File "env/lib/python3.10/site-packages/pymysql/cursors.py", line 148, in execute
    result = self._query(query)
  File "env/lib/python3.10/site-packages/pymysql/cursors.py", line 310, in _query
    conn.query(q)
  File "env/lib/python3.10/site-packages/pymysql/connections.py", line 548, in query
    self._affected_rows = self._read_query_result(unbuffered=unbuffered)
  File "env/lib/python3.10/site-packages/pymysql/connections.py", line 775, in _read_query_result
    result.read()
  File "env/lib/python3.10/site-packages/pymysql/connections.py", line 1156, in read
    first_packet = self.connection._read_packet()
  File "env/lib/python3.10/site-packages/pymysql/connections.py", line 725, in _read_packet
    packet.raise_for_error()
  File "env/lib/python3.10/site-packages/pymysql/protocol.py", line 221, in raise_for_error
    err.raise_mysql_exception(self._data)
  File "env/lib/python3.10/site-packages/pymysql/err.py", line 143, in raise_mysql_exception
    raise errorclass(errno, errval)
pymysql.err.IntegrityError: (1062, "Duplicate entry 'HR' for key 'PRIMARY'")

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "apps/frappe/frappe/commands/site.py", line 413, in install_app
    _install_app(app, verbose=context.verbose, force=force)
  File "apps/frappe/frappe/installer.py", line 288, in install_app
    add_module_defs(name, ignore_if_duplicate=force)
  File "apps/frappe/frappe/installer.py", line 608, in add_module_defs
    d.insert(ignore_permissions=True, ignore_if_duplicate=ignore_if_duplicate)
  File "apps/frappe/frappe/model/document.py", line 268, in insert
    self.db_insert(ignore_if_duplicate=ignore_if_duplicate)
  File "apps/frappe/frappe/model/base_document.py", line 526, in db_insert
    raise frappe.DuplicateEntryError(self.doctype, self.name, e)
frappe.exceptions.DuplicateEntryError: ('Module Def', 'HR', IntegrityError(1062, "Duplicate entry 'HR' for key 'PRIMARY'"))

Please do it like this.

bench --site site_name install-app hrms

Thank you sir. I run by “bench --site site_name install-app hrms”, but the same error.

Before installing hrms… make sure Bench is started… in another terminal window

bench start

And while the bench is running

bench --site site_name install-app hrms
2 Likes

You attempted to install the app on the site before now so you may have to remove the app first.

do the following
bench --site site_name uninstall-app hrms
bench remove-app hrms

if you still receive errors you can go to login to your site got to Module Def list and delete the app directly

How to do this specifically?

B.T.W
This error occurred with the system running in production mode.

Search for Module Def list
in the list find HR and delete it

Amazing! It can install like this operation only?
Thank you very much!

I got the same error. The solution is not working for me.
I guess if you replace the HR module from v13 to v14 there should be some workflow to make a smooth upgrade?
Are there any solutions available?

bench --site [sitename] mariadb

delete from tabModule Def where module_name = ‘HR’;

delete from tabModule Def where module_name = ‘Payroll’;

1 Like