Error While adding Item

I get a server error while adding item

Traceback (most recent call last):
File “/home/frappe/frappe-bench/apps/frappe/frappe/app.py”, line 61, in application
response = frappe.handler.handle()
File “/home/frappe/frappe-bench/apps/frappe/frappe/handler.py”, line 21, in handle
data = execute_cmd(cmd)
File “/home/frappe/frappe-bench/apps/frappe/frappe/handler.py”, line 56, in execute_cmd
return frappe.call(method, **frappe.form_dict)
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 1026, in call
return fn(*args, **newargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/client.py”, line 155, in insert
doc = frappe.get_doc(doc).insert()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 222, in insert
self.run_before_save_methods()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 876, in run_before_save_methods
self.run_method(“validate”)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 772, in run_method
out = Document.hook(fn)(self, *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 1048, in composer
return composed(self, method, *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 1031, in runner
add_to_return_value(self, fn(self, *args, **kwargs))
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 766, in
fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/stock/doctype/item/item.py”, line 128, in validate
self.validate_uom_conversion_factor()
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/stock/doctype/item/item.py”, line 759, in validate_uom_conversion_factor
value = get_uom_conv_factor(d.uom, self.stock_uom)
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/stock/doctype/item/item.py”, line 977, in get_uom_conv_factor
“”".format(', '.join([frappe.db.escape(i, percent=False) for i in uoms])), as_dict=True)
File “/home/frappe/frappe-bench/apps/frappe/frappe/database.py”, line 210, in sql
self._cursor.execute(query)
File “/home/frappe/frappe-bench/env/lib/python3.6/site-packages/pymysql/cursors.py”, line 170, in execute
result = self._query(query)
File “/home/frappe/frappe-bench/env/lib/python3.6/site-packages/pymysql/cursors.py”, line 328, in _query
conn.query(q)
File “/home/frappe/frappe-bench/env/lib/python3.6/site-packages/pymysql/connections.py”, line 517, in query
self._affected_rows = self._read_query_result(unbuffered=unbuffered)
File “/home/frappe/frappe-bench/env/lib/python3.6/site-packages/pymysql/connections.py”, line 732, in _read_query_result
result.read()
File “/home/frappe/frappe-bench/env/lib/python3.6/site-packages/pymysql/connections.py”, line 1075, in read
first_packet = self.connection._read_packet()
File “/home/frappe/frappe-bench/env/lib/python3.6/site-packages/pymysql/connections.py”, line 684, in _read_packet
packet.check_error()
File “/home/frappe/frappe-bench/env/lib/python3.6/site-packages/pymysql/protocol.py”, line 220, in check_error
err.raise_mysql_exception(self._data)
File “/home/frappe/frappe-bench/env/lib/python3.6/site-packages/pymysql/err.py”, line 109, in raise_mysql_exception
raise errorclass(errno, errval)
pymysql.err.InternalError: (1054, “Unknown column ‘Kg’ in ‘where clause’”)

Can you share/show your traceback/screens, and also the versions of your system and OS?

Ubuntu 18.10 (GNU/Linux 4.18.0-15-generic x86_64)

I did bench update / migrate and update batches with no errors, also site migrate, and bench restart

the installation is in production mode

I think some custom field with label Kg is missing.

Your screen shows develop mode, but your post says production mode. It also seems you have a mismatch on the framework vs ERPNext versions. You might need to do a bench migrate so they can sync up

no, Unit of measurement is an original field and is not a custom field. the KG is the value placed on that field and linked to Units of Measurement table Stock_UOM

I did Bench migrate several times, but it keep getting the same.

We pulled updates for V11 from 10, and it upgrades to V12 for ERPNext app

Anyway to fix this

this particular error can only occur if the database is getting an insert command for a non-existant column. Go to Custom Field, filter by Doctype Item and see if there is such a field or not.

bench switch-to-master and then bench update --patch should help erpnext migrate to v11

Did that before, did not fix it

Some patch got missed in update. These column error generally comes when we skip the migrate or update without patches.

so how to fix it??

Something in the lines of what @root13F has suggested about, trying to reapply the patch. Alternatively, Just try to find out Column errors in the forums you should be able to find some fixes.

Bench update Tracking

Traceback (most recent call last):
File “/usr/lib/python3.6/runpy.py”, line 193, in _run_module_as_main
main”, mod_spec)
File “/usr/lib/python3.6/runpy.py”, line 85, in _run_code
exec(code, run_globals)
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 97, in
main()
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 18, in main
click.Group(commands=commands)(prog_name=‘bench’)
File “/home/frappe/frappe-bench/env/lib/python3.6/site-packages/click/core.py”, line 764, in call
return self.main(*args, **kwargs)
File “/home/frappe/frappe-bench/env/lib/python3.6/site-packages/click/core.py”, line 717, in main
rv = self.invoke(ctx)
File “/home/frappe/frappe-bench/env/lib/python3.6/site-packages/click/core.py”, line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/frappe/frappe-bench/env/lib/python3.6/site-packages/click/core.py”, line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/frappe/frappe-bench/env/lib/python3.6/site-packages/click/core.py”, line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/home/frappe/frappe-bench/env/lib/python3.6/site-packages/click/core.py”, line 555, in invoke
return callback(*args, **kwargs)
File “/home/frappe/frappe-bench/env/lib/python3.6/site-packages/click/decorators.py”, line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/commands/init.py”, line 25, in _func
ret = f(frappe.dict(ctx.obj), *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/commands/site.py”, line 302, in backup
odb = scheduled_backup(ignore_files=not with_files, backup_path_db=backup_path_db, backup_path_files=backup_path_files, backup_path_private_files=backup_path_private_files, force=True)
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/backups.py”, line 170, in scheduled_backup
odb = new_backup(older_than, ignore_files, backup_path_db=backup_path_db, backup_path_files=backup_path_files, force=force)
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/backups.py”, line 180, in new_backup
odb.get_backup(older_than, ignore_files, force=force)
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/backups.py”, line 48, in get_backup
self.set_backup_file_name()
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/backups.py”, line 61, in set_backup_file_name
todays_date = now_datetime().strftime('%Y%m%d
%H%M%S’)
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/data.py”, line 121, in now_datetime
dt = convert_utc_to_user_timezone(datetime.datetime.utcnow())
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/data.py”, line 144, in convert_utc_to_user_timezone
return utcnow.astimezone(timezone(get_time_zone()))
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/data.py”, line 138, in get_time_zone
return frappe.cache().get_value(“time_zone”, _get_time_zone)
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/redis_wrapper.py”, line 79, in get_value
val = generator()
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/data.py”, line 132, in _get_time_zone
return frappe.db.get_system_setting(‘time_zone’) or ‘Asia/Kolkata’ # Default to India ?!
File “/home/frappe/frappe-bench/apps/frappe/frappe/database.py”, line 943, in get_system_setting
return frappe.cache().get_value(“system_settings”, _load_system_settings).get(key)
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/redis_wrapper.py”, line 79, in get_value
val = generator()
File “/home/frappe/frappe-bench/apps/frappe/frappe/database.py”, line 942, in _load_system_settings
return self.get_singles_dict(“System Settings”)
File “/home/frappe/frappe-bench/apps/frappe/frappe/database.py”, line 603, in get_singles_dict
“”", doctype)
File “/home/frappe/frappe-bench/apps/frappe/frappe/database.py”, line 165, in sql
self.connect()
File “/home/frappe/frappe-bench/apps/frappe/frappe/database.py”, line 115, in connect
charset=‘utf8mb4’, use_unicode = True, conv = conversions, local_infile = self.local_infile)
File “/home/frappe/frappe-bench/env/lib/python3.6/site-packages/pymysql/init.py”, line 94, in Connect
return Connection(*args, **kwargs)
File “/home/frappe/frappe-bench/env/lib/python3.6/site-packages/pymysql/connections.py”, line 325, in init
self.connect()
File “/home/frappe/frappe-bench/env/lib/python3.6/site-packages/pymysql/connections.py”, line 599, in connect
self._request_authentication()
File “/home/frappe/frappe-bench/env/lib/python3.6/site-packages/pymysql/connections.py”, line 861, in _request_authentication
auth_packet = self._read_packet()
File “/home/frappe/frappe-bench/env/lib/python3.6/site-packages/pymysql/connections.py”, line 684, in _read_packet
packet.check_error()
File “/home/frappe/frappe-bench/env/lib/python3.6/site-packages/pymysql/protocol.py”, line 220, in check_error
err.raise_mysql_exception(self._data)
File “/home/frappe/frappe-bench/env/lib/python3.6/site-packages/pymysql/err.py”, line 109, in raise_mysql_exception
raise errorclass(errno, errval)
pymysql.err.OperationalError: (1045, “Access denied for user ‘_6d4b9452aef14153’@‘localhost’ (using password: YES)”)

It seems mysql user password for this site is denied access. It seems further debugging may help.

Dear All, problem solved, but with non of the solutions above.

It was our mistake to upgrade ERPNext app to V12 while frappe and bench is on V11, this caused several problems related to bench update and bench-manager and the ERPNext application fields and some DocTypes.

How we solve it:
First don’t forget to take backup from your sites database - very important (We did that manually from MariaDB), if you forgot you can find previous backups under sites/site name/private/backup

We had removed Bench-manager app manually (removed the folder and site, then remove the database and user)

Re-install Bench manager, and bench manager site

Remove ERPNext app folder manually
Re-install ERPNext App

From banch manager after login after sites ( go to your site and click install APP)

This will install frappe app on the site, then click install app again, it will give you the option to install ERPNext app, select ERPNext and click install

Now your site had been reset, no data, if you try to login you will get the setup wizard

Go to database and restore backup

Then Login again, you will find everything back again.

go to SSH, do Bench update
and Bench update --patch
it should not give you any errors

After login to erpnext app, go to help about
you will find all apps version switched to V11