ValueError: min() arg is an empty sequence

I have faced an error “ValueError: min() arg is an empty sequence” in my .py file.
my code:
if not zero_flag :
key = min(qty_dict.items(), key=lambda x: int(x[1]))
val = int(qty_dict[key[0]])
return val
else:
return 0
Error:

Traceback (most recent call last):
File “/home/frappe/frappe-bench/apps/frappe/frappe/app.py”, line 62, in application
response = frappe.handler.handle()
File “/home/frappe/frappe-bench/apps/frappe/frappe/handler.py”, line 22, in handle
data = execute_cmd(cmd)
File “/home/frappe/frappe-bench/apps/frappe/frappe/handler.py”, line 53, in execute_cmd
return frappe.call(method, **frappe.form_dict)
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 939, in call
return fn(*args, **newargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/desk/query_report.py”, line 96, in run
res = frappe.get_attr(method_name)(frappe._dict(filters))
File “/home/frappe/frappe-bench/apps/footwear_erpnext/footwear_erpnext/footwear_production/report/department_transfer_report/department_transfer_report.py”, line 12, in execute
data = get_data(filters)
File “/home/frappe/frappe-bench/apps/footwear_erpnext/footwear_erpnext/footwear_production/report/department_transfer_report/department_transfer_report.py”, line 75, in get_data
data = add_rows(data)
File “/home/frappe/frappe-bench/apps/footwear_erpnext/footwear_erpnext/footwear_production/report/department_transfer_report/department_transfer_report.py”, line 92, in add_rows
row = setRow_dict(row, “PREPARATION”, wrk_order)
File “/home/frappe/frappe-bench/apps/footwear_erpnext/footwear_erpnext/footwear_production/report/department_transfer_report/department_transfer_report.py”, line 122, in setRow_dict
finish_stock = finish_stock + int(getFinishStock(wrk_station_to_trns_qty,workstation_name))
File “/home/frappe/frappe-bench/apps/footwear_erpnext/footwear_erpnext/footwear_production/report/department_transfer_report/department_transfer_report.py”, line 174, in getFinishStock
key = min(qty_dict.items(), key=lambda x: int(x[1]))
ValueError: min() arg is an empty sequence

Any help?

Seems qty_dict is empty

1 Like