Error in sales invoice when i try to cancel

App Versions

	"agriculture": "0.0.1",
	"chat": "0.0.1",
	"education": "15.0.0",
	"erpnext": "15.19.2",
	"frappe": "15.20.0",
	"hrms": "15.16.0",
	"india_compliance": "15.7.1"


Form/Sales Invoice/SI24B25/I/00107


Traceback (most recent call last):
  File "apps/frappe/frappe/", line 110, in application
    response = frappe.api.handle(request)
  File "apps/frappe/frappe/api/", line 49, in handle
    data = endpoint(**arguments)
  File "apps/frappe/frappe/api/", line 36, in handle_rpc_call
    return frappe.handler.handle()
  File "apps/frappe/frappe/", line 49, in handle
    data = execute_cmd(cmd)
  File "apps/frappe/frappe/", line 85, in execute_cmd
    return, **frappe.form_dict)
  File "apps/frappe/frappe/", line 1718, in call
    return fn(*args, **newargs)
  File "apps/frappe/frappe/utils/", line 31, in wrapper
    return func(*args, **kwargs)
  File "apps/frappe/frappe/desk/form/", line 57, in cancel
  File "apps/frappe/frappe/utils/", line 31, in wrapper
    return func(*args, **kwargs)
  File "apps/frappe/frappe/model/", line 1053, in cancel
    return self._cancel()
  File "apps/frappe/frappe/model/", line 1036, in _cancel
  File "apps/frappe/frappe/model/", line 337, in save
    return self._save(*args, **kwargs)
  File "apps/frappe/frappe/model/", line 390, in _save
  File "apps/frappe/frappe/model/", line 1133, in run_post_save_methods
  File "apps/frappe/frappe/model/", line 962, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "apps/frappe/frappe/model/", line 1322, in composer
    return composed(self, method, *args, **kwargs)
  File "apps/frappe/frappe/model/", line 1304, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "apps/frappe/frappe/model/", line 959, in fn
    return method_object(*args, **kwargs)
  File "apps/erpnext/erpnext/accounts/doctype/sales_invoice/", line 545, in on_cancel
  File "apps/erpnext/erpnext/controllers/", line 165, in update_prevdoc_status
  File "apps/erpnext/erpnext/controllers/", line 226, in validate_qty
    if hasattr(d, "qty") and d.qty < 0 and not self.get("is_return"):
TypeError: '<' not supported between instances of 'NoneType' and 'int'

Request Data

	"type": "POST",
	"args": {
		"doctype": "Sales Invoice",
		"name": "SI24B25/I/00107"
	"btn": {
		"jQuery3700302331948329746861": {
			"events": {
				"click": [
						"type": "click",
						"origType": "click",
						"guid": 13554,
						"namespace": ""
	"freeze": true,
	"headers": {},
	"error_handlers": {},
	"url": "/api/method/",
	"request_id": null

Response Data

	"exception": "TypeError: '<' not supported between instances of 'NoneType' and 'int'",
	"exc_type": "TypeError",
	"_exc_source": "erpnext (app)"

Tested. Everything is working fine. No problems were encountered in the latest version 15.

Please check it.

You have to update your version 15, because lots of bugs fixed in the new version.

I think this is because i have added a new table in sales invoice when i delete that table the issue got solved

Otherwise, everything works properly in the default functionality. We did not find any issues. If customization is done, then you have to handle it yourself, if any script is added, any field is added, any logic is added in it, then some such issue may arise. Otherwise there is no issue.

yes I have added scripts and field