Unable to save data with customized form (receiving DB error)

Hello,

I want to add descriptive metadata to any item that has a serial number. For example, if the item is a WiFi router, then for each serial number in stock I would like to add the default network ID and password. This would be a text name-value pair and appear in a table.

To do this, I first created a new, custom doctype that has 2 text fields - one for the name, one for the value. Then I customized the “Serial No” form and added a table. In the options field I entered the name of the new custom doctype. All of this was successful.

However, once I open an actual serial number and try to add data to the new fields, the form is displayed correctly and allows data entry, but I get an error when trying to save the changes. It is a DB error saying that the table for the custom form doesn’t exist.

I have posted everything in the following GitHub issue but no one has looked at it yet:

https://github.com/frappe/erpnext/issues/16698

Can someone here help?

Thanks!

can you share the screenshot of the issue and traceback?

Hi @arokia ,

The traceback is in the GitHub issue, along with a detailed description of the steps and also the version information. Please click through to it using the link above, if you don’t mind.

As for screenshots, I am attaching several:

  1. Custom DocType - Part 1
  2. Custom DocType - Part 2 (showing permissions area)
  3. Custom DocType - Part 3: Field 1 Details
  4. Custom DocType - Part 4: Field 2 Details
  5. Customize Form page for form “Serial No” - Part 1
  6. Customize Form page for form “Serial No” - Part 2
  7. Customize Form page for form “Serial No” - Part 3: Details of the added Table
  8. Animated GIF of error

com-resize

When you say any item that has a serial number, do you mean a Serialized Item in the ERPNext sense or a manufacturer’s serial number?

In the ERPNext sense. Then, the manufacturer’s serial number can be captured as one of the descriptive metadata entries, along with other information.

I was able to create a custom doctype with two fields, Label and name foo and bar, Data and Text. Both mandatory. Did not add any Permission Rules.

I customized Serial No. form , added two rows, Labels foo and bar, Types Data and Text , and option the name of the new doctype.

It seems to work if I add a new serial number. . I’m not sure it is what you are after.

Thanks @smino . The difference is that I am unable to save the new serial number due to a DB error (table not found). I am pasting my stack trace below.

I also noticed in the meantime that I am unable to rename the custom doctype because of the same error (table not found).

Application versions:

  • “erpnext”: “10.1.76”
  • “frappe”: “10.1.69”

Error message/traceback:

Traceback (most recent call last):
File “/home/erpnext/vendor/frappe/frappe-bench/apps/frappe/frappe/desk/form/save.py”, line 22, in savedocs
doc.save()
File “/home/erpnext/vendor/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 259, in save
return self._save(*args, **kwargs)
File “/home/erpnext/vendor/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 311, in _save
self.update_children()
File “/home/erpnext/vendor/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 337, in update_children
self.update_child_table(df.fieldname, df)
File “/home/erpnext/vendor/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 346, in update_child_table
d.db_update()
File “/home/erpnext/vendor/frappe/frappe-bench/apps/frappe/frappe/model/base_document.py”, line 335, in db_update
self.db_insert()
File “/home/erpnext/vendor/frappe/frappe-bench/apps/frappe/frappe/model/base_document.py”, line 312, in db_insert
), list(d.values()))
File “/home/erpnext/vendor/frappe/frappe-bench/apps/frappe/frappe/database/database.py”, line 155, in sql
self._cursor.execute(query, values)
File “/home/erpnext/vendor/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/cursors.py”, line 165, in execute
result = self._query(query)
File “/home/erpnext/vendor/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/cursors.py”, line 321, in _query
conn.query(q)
File “/home/erpnext/vendor/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/connections.py”, line 860, in query
self._affected_rows = self._read_query_result(unbuffered=unbuffered)
File “/home/erpnext/vendor/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/connections.py”, line 1061, in _read_query_result
result.read()
File “/home/erpnext/vendor/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/connections.py”, line 1349, in read
first_packet = self.connection._read_packet()
File “/home/erpnext/vendor/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/connections.py”, line 1018, in _read_packet
packet.check_error()
File “/home/erpnext/vendor/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/connections.py”, line 384, in check_error
err.raise_mysql_exception(self._data)
File “/home/erpnext/vendor/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/err.py”, line 107, in raise_mysql_exception
raise errorclass(errno, errval)
ProgrammingError: (1146, u"Table ‘b9b38ed869e63e1f.tabItem Single Descriptive Metadata’ doesn’t exist")

Traceback (most recent call last):
File “/home/erpnext/vendor/frappe/frappe-bench/apps/frappe/frappe/app.py”, line 55, in application
response = frappe.handler.handle()
File “/home/erpnext/vendor/frappe/frappe-bench/apps/frappe/frappe/handler.py”, line 20, in handle
data = execute_cmd(cmd)
File “/home/erpnext/vendor/frappe/frappe-bench/apps/frappe/frappe/handler.py”, line 55, in execute_cmd
return frappe.call(method, **frappe.form_dict)
File “/home/erpnext/vendor/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 1013, in call
return fn(*args, **newargs)
File “/home/erpnext/vendor/frappe/frappe-bench/apps/frappe/frappe/desk/form/save.py”, line 22, in savedocs
doc.save()
File “/home/erpnext/vendor/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 259, in save
return self._save(*args, **kwargs)
File “/home/erpnext/vendor/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 311, in _save
self.update_children()
File “/home/erpnext/vendor/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 337, in update_children
self.update_child_table(df.fieldname, df)
File “/home/erpnext/vendor/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 346, in update_child_table
d.db_update()
File “/home/erpnext/vendor/frappe/frappe-bench/apps/frappe/frappe/model/base_document.py”, line 335, in db_update
self.db_insert()
File “/home/erpnext/vendor/frappe/frappe-bench/apps/frappe/frappe/model/base_document.py”, line 312, in db_insert
), list(d.values()))
File “/home/erpnext/vendor/frappe/frappe-bench/apps/frappe/frappe/database/database.py”, line 155, in sql
self._cursor.execute(query, values)
File “/home/erpnext/vendor/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/cursors.py”, line 165, in execute
result = self._query(query)
File “/home/erpnext/vendor/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/cursors.py”, line 321, in _query
conn.query(q)
File “/home/erpnext/vendor/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/connections.py”, line 860, in query
self._affected_rows = self._read_query_result(unbuffered=unbuffered)
File “/home/erpnext/vendor/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/connections.py”, line 1061, in _read_query_result
result.read()
File “/home/erpnext/vendor/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/connections.py”, line 1349, in read
first_packet = self.connection._read_packet()
File “/home/erpnext/vendor/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/connections.py”, line 1018, in _read_packet
packet.check_error()
File “/home/erpnext/vendor/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/connections.py”, line 384, in check_error
err.raise_mysql_exception(self._data)
File “/home/erpnext/vendor/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/err.py”, line 107, in raise_mysql_exception
raise errorclass(errno, errval)
ProgrammingError: (1146, u"Table ‘b9b38ed869e63e1f.tabItem Single Descriptive Metadata’ doesn’t exist")

What I am suggesting is that instead of having a table in your new DocType, you simply add rows as described.

New Doctype:

Customized Serial No. form:

I suspect the way you are doing it results in error because you are trying to link table when table elements need to be linked, I don’t see why a table inside the doctype is needed?