Resilient error "Debit to is required"

This error keeps popping up on erpnext; preventing printing of sales invoice and some other operations; the javascript sort of blocks after the first print. If you reload the browser, pos prints once and afterwards throws a validation exception and the print button does nothing. Image attached.

NOTE*** I tried the pos on erpnext own cloud, and it’s the same! after one sale; pos will not print again. this seems to be serious error. So it seems there’s a serious issue with the offline storage

from erpnext.com cloud:

`Traceback (most recent call last):
File “/home/frappe/benches/bench-2016-11-28-a/apps/frappe/frappe/app.py”, line 55, in application
response = frappe.handler.handle()
File “/home/frappe/benches/bench-2016-11-28-a/apps/frappe/frappe/handler.py”, line 19, in handle
execute_cmd(cmd)
File “/home/frappe/benches/bench-2016-11-28-a/apps/frappe/frappe/handler.py”, line 36, in execute_cmd
ret = frappe.call(method, **frappe.form_dict)
File “/home/frappe/benches/bench-2016-11-28-a/apps/frappe/frappe/init.py”, line 890, in call
return fn(*args, **newargs)
File “/home/frappe/benches/bench-2016-11-28-a/apps/erpnext/erpnext/accounts/doctype/sales_invoice/pos.py”, line 249, in make_invoice
submit_invoice(si_doc, name)
File “/home/frappe/benches/bench-2016-11-28-a/apps/erpnext/erpnext/accounts/doctype/sales_invoice/pos.py”, line 292, in submit_invoice
save_invoice(e, si_doc, name)
File “/home/frappe/benches/bench-2016-11-28-a/apps/erpnext/erpnext/accounts/doctype/sales_invoice/pos.py”, line 299, in save_invoice
frappe.log_error(frappe.get_traceback())
File “/home/frappe/benches/bench-2016-11-28-a/apps/frappe/frappe/init.py”, line 1268, in log_error
method=title)).insert(ignore_permissions=True)
File “/home/frappe/benches/bench-2016-11-28-a/apps/frappe/frappe/model/document.py”, line 214, in insert
self.db_insert()
File “/home/frappe/benches/bench-2016-11-28-a/apps/frappe/frappe/model/base_document.py”, line 296, in db_insert
), d.values())
File “/home/frappe/benches/bench-2016-11-28-a/apps/frappe/frappe/database.py”, line 137, in sql
self._cursor.execute(query, values)
File “/home/frappe/benches/bench-2016-11-28-a/env/lib/python2.7/site-packages/MySQLdb/cursors.py”, line 205, in execute
self.errorhandler(self, exc, value)
File “/home/frappe/benches/bench-2016-11-28-a/env/lib/python2.7/site-packages/MySQLdb/connections.py”, line 36, in defaulterrorhandler
raise errorclass, errorvalue
DuplicateEntryError: (u’Error Log’, u’Error-00001’, IntegrityError(1062, “Duplicate entry ‘Error-00001’ for key ‘PRIMARY’”))

desk.min.js (150,95)`

I have made a clean install today and only restored the database, can someone guide as to where this may be coming from. I also noticed that you may have the system throwing error for items that dont exist anymore; browser cache has been cleared; website cache also cleared; makes no difference, customized forms reset to default; error logs cleared; nothing seems to solve it. Even updates, patches and build. Any hints?

error

Traceback (most recent call last):

File “/home/frappe/frappe-bench/apps/frappe/frappe/app.py”, line 55, in application
response = frappe.handler.handle()
File “/home/frappe/frappe-bench/apps/frappe/frappe/handler.py”, line 19, in handle
execute_cmd(cmd)
File “/home/frappe/frappe-bench/apps/frappe/frappe/handler.py”, line 36, in execute_cmd
ret = frappe.call(method, **frappe.form_dict)
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 890, in call
return fn(*args, **newargs)
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/accounts/doctype/sales_invoice/pos.py”, line 249, in make_invoice
submit_invoice(si_doc, name)
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/accounts/doctype/sales_invoice/pos.py”, line 292, in submit_invoice
save_invoice(e, si_doc, name)
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/accounts/doctype/sales_invoice/pos.py”, line 298, in save_invoice
si_doc.insert()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 203, in insert
self.run_before_save_methods()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 754, in run_before_save_methods
self.run_method(“validate”)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 655, in run_method
out = Document.hook(fn)(self, *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 883, in composer
return composed(self, method, *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 866, in runner
add_to_return_value(self, fn(self, *args, **kwargs))
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 649, in
fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/accounts/doctype/sales_invoice/sales_invoice.py”, line 61, in validate
self.validate_debit_to_acc()
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/accounts/doctype/sales_invoice/sales_invoice.py”, line 324, in validate_debit_to_acc
frappe.throw(_(“Debit To is required”))
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 300, in throw
msgprint(msg, raise_exception=exc, title=title, indicator=‘red’)
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 293, in msgprint
_raise_exception()
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 266, in _raise_exception
raise raise_exception, encode(msg)
ValidationError: Debit To is required

desk.min.js (150,95)

UPDATE: This error keeps coming on to the screen randomly; if the pos screen is reloaded; you can print one sale and after that the error starts; reload the page and you can print one invoice again and you jam up; click the print, nothing happens.


For creating Sales Invoice, you need to define default Debit To account. For the POS invoice, you can define the same via Point of Sales Profile.

You can create new POS Profile from:

Accounts > Point of Sale Profile > New

Thanks @umair

The default debit to is defined and pos profiles all setup; these are actually initial steps before testing the pos and we have been using erpnext for quite a while; this appears to be a real issue with the way offline invoices are handled; @rohit_w has assured there’s going to be a way to sanitize the storage.

Kent@Live Mail

Please note also that we set Default for Debit To in “Customize form” for sales invoice. This has been like this before the upgrade. I do not see any Debit to account in pos profiles; there has never been a field like this in pos profiles; only we set this in Default for the Debit To field.