There was an issue while migrating the DocType: Sales Invoice Item

Tried to update from
ERPNext: v13.15.1 to ERPNext: v13.16.1

The problem is with the Sales Invoice Item Doctype i guess having invalid datetime value.

Any help is appreciated.

Everything went smooth except while updating Erpnext doctypes.

Patching sites…
Migrating site1.local
Updating DocTypes for frappe : [====================] 100%
Updating DocTypes for erpnext : [= ] 7%

There was an issue while migrating the DocType: Sales Invoice Item

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 104, in
main()
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 19, in main
click.Group(commands=commands)(prog_name=‘bench’)
File “/home/frappe/frappe-bench/env/lib/python3.6/site-packages/click/core.py”, line 829, in call
return self.main(*args, **kwargs)
File “/home/frappe/frappe-bench/env/lib/python3.6/site-packages/click/core.py”, line 782, in main
rv = self.invoke(ctx)
File “/home/frappe/frappe-bench/env/lib/python3.6/site-packages/click/core.py”, line 1259, 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 1259, 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 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/home/frappe/frappe-bench/env/lib/python3.6/site-packages/click/core.py”, line 610, in invoke
return callback(*args, **kwargs)
File “/home/frappe/frappe-bench/env/lib/python3.6/site-packages/click/decorators.py”, line 21, in new_func
return f(get_current_context(), *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/commands/init.py”, line 27, in _func
ret = f(frappe._dict(ctx.obj), *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/commands/site.py”, line 309, in migrate
skip_search_index=skip_search_index
File “/home/frappe/frappe-bench/apps/frappe/frappe/migrate.py”, line 72, in migrate
frappe.model.sync.sync_all(verbose=verbose)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/sync.py”, line 19, in sync_all
sync_for(app, force, verbose=verbose, reset_permissions=reset_permissions)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/sync.py”, line 70, in sync_for
import_file_by_path(doc_path, force=force, ignore_version=True, reset_permissions=reset_permissions)
File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/import_file.py”, line 135, in import_file_by_path
path=path,
File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/import_file.py”, line 255, in import_doc
doc.insert()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 268, in insert
self.run_post_save_methods()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 1001, in run_post_save_methods
self.run_method(“on_update”)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 860, in run_method
out = Document.hook(fn)(self, *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 1158, in composer
return composed(self, method, *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 1141, in runner
add_to_return_value(self, fn(self, *args, **kwargs))
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 854, in
fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/doctype/doctype.py”, line 302, in on_update
raise e
File “/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/doctype/doctype.py”, line 299, in on_update
frappe.db.updatedb(self.name, Meta(self))
File “/home/frappe/frappe-bench/apps/frappe/frappe/database/mariadb/database.py”, line 298, in updatedb
db_table.sync()
File “/home/frappe/frappe-bench/apps/frappe/frappe/database/schema.py”, line 40, in sync
self.alter()
File “/home/frappe/frappe-bench/apps/frappe/frappe/database/mariadb/schema.py”, line 88, in alter
raise e
File “/home/frappe/frappe-bench/apps/frappe/frappe/database/mariadb/schema.py”, line 75, in alter
frappe.db.sql(query)
File “/home/frappe/frappe-bench/apps/frappe/frappe/database/database.py”, line 154, in sql
self._cursor.execute(query)
File “/home/frappe/frappe-bench/env/lib/python3.6/site-packages/pymysql/cursors.py”, line 148, in execute
result = self._query(query)
File “/home/frappe/frappe-bench/env/lib/python3.6/site-packages/pymysql/cursors.py”, line 310, in _query
conn.query(q)
File “/home/frappe/frappe-bench/env/lib/python3.6/site-packages/pymysql/connections.py”, line 548, 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 775, in _read_query_result
result.read()
File “/home/frappe/frappe-bench/env/lib/python3.6/site-packages/pymysql/connections.py”, line 1156, in read
first_packet = self.connection._read_packet()
File “/home/frappe/frappe-bench/env/lib/python3.6/site-packages/pymysql/connections.py”, line 725, in _read_packet
packet.raise_for_error()
File “/home/frappe/frappe-bench/env/lib/python3.6/site-packages/pymysql/protocol.py”, line 221, in raise_for_error
err.raise_mysql_exception(self._data)
File “/home/frappe/frappe-bench/env/lib/python3.6/site-packages/pymysql/err.py”, line 143, in raise_mysql_exception
raise errorclass(errno, errval)
pymysql.err.OperationalError: (1292, “Incorrect datetime value: ‘’”)

Hi,

Have you made any customizations to the Sales Invoice Item doctype? Any Sales Invoices entered since the last update should be looked at ( maybe in list view) to see if a malformed entry was made in a date field.

Just few custom fields. That’s it.I thought of checking the invoices but I am unable to login as it shows Your system is being updated. Please refresh again after a few moments.

Tried the maintenance mode off but still no success at login.

@Touseef do you have server access?

At this point might be better to directly access the db and check.

Yes i do have access as it is local VM instance. I tried to lookup DB for the datetime field in Sales invoices but could not find any issues there.
Don’t exactly know what Incorrect datetime value: ‘ ’ ” is and where is it pointing to as no column and row is mentioned in the error. Too hard for me dig in.