HR Dashboard "Server Error"

When I open the HR Dashboard view, I get the below server error;

“pymysql.err.OperationalError: (1054, “Unknown column ‘employment_type’ in ‘GROUP BY’”)”

Then I uninstall and reinstalled the HRMS module again, and then when I open the HR Dashboard view, I get a different server error;

“pymysql.err.OperationalError: (1054, “Unknown column ‘grade’ in ‘GROUP BY’”)”

Error Details:

App Versions

{
	"erpnext": "15.19.1",
	"frappe": "15.20.0",
	"hrms": "15.42.0",
	"non_profit": "0.0.1",
	"payments": "0.0.1",
	"woocommerce_fusion": "1.13.6"
}

Route

dashboard-view/Human Resource

Traceback

Traceback (most recent call last):
  File "apps/frappe/frappe/app.py", line 110, in application
    response = frappe.api.handle(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/api/__init__.py", line 49, in handle
    data = endpoint(**arguments)
           ^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/api/v1.py", line 36, in handle_rpc_call
    return frappe.handler.handle()
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/handler.py", line 49, in handle
    data = execute_cmd(cmd)
           ^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/handler.py", line 85, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/__init__.py", line 1718, in call
    return fn(*args, **newargs)
           ^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/utils/typing_validations.py", line 31, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/utils/dashboard.py", line 26, in wrapper
    results = generate_and_cache_results(kwargs, function, cache_key, chart)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/utils/dashboard.py", line 41, in generate_and_cache_results
    results = function(
              ^^^^^^^^^
  File "apps/frappe/frappe/desk/doctype/dashboard_chart/dashboard_chart.py", line 131, in get
    chart_config = get_group_by_chart_config(chart, filters)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/desk/doctype/dashboard_chart/dashboard_chart.py", line 269, in get_group_by_chart_config
    data = frappe.get_list(
           ^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/__init__.py", line 1982, in get_list
    return frappe.model.db_query.DatabaseQuery(doctype).execute(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/db_query.py", line 191, in execute
    result = self.build_and_run()
             ^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/db_query.py", line 232, in build_and_run
    return frappe.db.sql(
           ^^^^^^^^^^^^^^
  File "apps/frappe/frappe/database/database.py", line 234, in sql
    self._cursor.execute(query, values)
  File "env/lib/python3.11/site-packages/pymysql/cursors.py", line 153, in execute
    result = self._query(query)
             ^^^^^^^^^^^^^^^^^^
  File "env/lib/python3.11/site-packages/pymysql/cursors.py", line 322, in _query
    conn.query(q)
  File "env/lib/python3.11/site-packages/pymysql/connections.py", line 558, in query
    self._affected_rows = self._read_query_result(unbuffered=unbuffered)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "env/lib/python3.11/site-packages/pymysql/connections.py", line 822, in _read_query_result
    result.read()
  File "env/lib/python3.11/site-packages/pymysql/connections.py", line 1200, in read
    first_packet = self.connection._read_packet()
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "env/lib/python3.11/site-packages/pymysql/connections.py", line 772, in _read_packet
    packet.raise_for_error()
  File "env/lib/python3.11/site-packages/pymysql/protocol.py", line 221, in raise_for_error
    err.raise_mysql_exception(self._data)
  File "env/lib/python3.11/site-packages/pymysql/err.py", line 143, in raise_mysql_exception
    raise errorclass(errno, errval)
pymysql.err.OperationalError: (1054, "Unknown column 'employment_type' in 'GROUP BY'")

Request Data

{
	"type": "POST",
	"args": {
		"chart_name": "Employees by Type",
		"filters": "[[\"Employee\",\"status\",\"=\",\"Active\",false],[\"Employee\",\"company\",\"=\",\"digitalmarine24 (Demo)\"]]",
		"refresh": 1,
		"time_interval": null,
		"timespan": null,
		"from_date": null,
		"to_date": null,
		"heatmap_year": null
	},
	"headers": {},
	"error_handlers": {},
	"url": "/api/method/frappe.desk.doctype.dashboard_chart.dashboard_chart.get",
	"request_id": null
}

Response Data

{
	"exception": "pymysql.err.OperationalError: (1054, \"Unknown column 'employment_type' in 'GROUP BY'\")",
	"exc_type": "OperationalError"
}

Error:

Migrate the Bench using bench migrate and then clear the cache and restart the bench and check still error came

Things that I already tried;

bench --site [sitename] uninstall-app hrms --force
bench --site [sitename] migrate

bench remove-app hrms

bench get-app --branch version-15 hrms
bench --site [sitename] install-app hrms
bench --site [sitename] migrate
bench clear-cache
bench start again or bench restart

Try this and still not solve once run bench build command also

I just ran the below commands

bench clear-cache
bench build

and it made things worse. I have installed the ERPNext instance in a Docker Container. Inside the docker container I ran the Bench Build. Now the UI doesn’t display correctly. How to solve this? It’s urgent

Also when I ran those commands, I got a warning message;

frappe@b28c1765dec1:~/frappe-bench$ bench build
Assets for Release /bin/sh: 1: Syntax error: "(" unexpected don't exist
✔ Application Assets Linked

You have not to run bench build in Docker
You have to Tell Initially that you are using Docker

Now,

1 Stop and Remove the Running Containers

docker compose down

2. Rebuild and Start Fresh Containers

docker compose up -d --build

3. Clear Redis Cache (if assets still broken)

  • Sometimes, Redis cache holds onto old asset references. Clear it by running:
docker exec -it <redis-cache-container-name> redis-cli FLUSHALL

4. Clear Frappe Cache

docker exec -it <frappe-container-name> bench clear-cache
docker exec -it <frappe-container-name> bench clear-website-cache

5. Refresh Your Browser
Use incognito mode or clear your browser cache to avoid loading old assets

I did like you said and now the Containers won’t run. Is there are any solution for that? I even tried building the container but no luck.

root@vmd155741:~# cd docker
root@vmd155741:~/docker# ls
erpnext  n8n  nginx-proxy-manager
root@vmd155741:~/docker# cd erpnext/
root@vmd155741:~/docker/erpnext# docker exec -it erpnext-backend-1 bench update --build
ERROR: Command 'basename $(git symbolic-ref -q HEAD)' returned non-zero exit status 1.
Traceback (most recent call last):
  File "/usr/local/bin/bench", line 8, in <module>
    sys.exit(cli())
             ^^^^^
  File "/usr/local/lib/python3.11/site-packages/bench/cli.py", line 132, in cli
    bench_command()
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/bench/commands/update.py", line 59, in update
    update(
  File "/usr/local/lib/python3.11/site-packages/bench/utils/bench.py", line 457, in update
    validate_branch()
  File "/usr/local/lib/python3.11/site-packages/bench/utils/bench.py", line 644, in validate_branch
    branch = get_current_branch(app)
             ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/bench/utils/app.py", line 175, in get_current_branch
    return get_cmd_output("basename $(git symbolic-ref -q HEAD)", cwd=repo_dir)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/bench/utils/__init__.py", line 228, in get_cmd_output
    output = subprocess.check_output(
             ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/subprocess.py", line 466, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command 'basename $(git symbolic-ref -q HEAD)' returned non-zero exit status 1.
INFO: A newer version of bench is available: 5.22.3 → 5.25.1

You not have to use bench build and bench updates in Docker Container

This are the tips you may follow while working with docker

  • Never use bench update inside containers built from official images. This will fail due to missing .git directories
  • Always backup before upgrades or downgrades. Downgrades are riskier and may cause schema conflicts—restoring from backup is the safest rollback
  • For custom app development: Use Git repositories and development containers with .git directories if you need to use bench update or branch switching
  • For multi-environment setups: Use separate Docker Compose files and databases for production, staging, etc., to isolate changes and test upgrades safely

(post deleted by author)

I’m new to configuring ERPNext with Docker, although I have experience setting up ERPNext on virtual machines. Your information was really helpful—thank you so much!

How to run “bench build” in a docker environment? Is there a proper way to do it safely? I also want to know if that UI issue can be resolved using the below command (if there’s a permission related issue),

chmod 701 /home/<frappe-user>