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"
}

Route

Form/Sales Invoice/SI24B25/I/00107

Traceback

Traceback (most recent call last):
  File "apps/frappe/frappe/app.py", line 110, in application
    response = frappe.api.handle(request)
  File "apps/frappe/frappe/api/__init__.py", line 49, in handle
    data = endpoint(**arguments)
  File "apps/frappe/frappe/api/v1.py", line 36, in handle_rpc_call
    return frappe.handler.handle()
  File "apps/frappe/frappe/handler.py", line 49, in handle
    data = execute_cmd(cmd)
  File "apps/frappe/frappe/handler.py", line 85, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
  File "apps/frappe/frappe/__init__.py", line 1718, in call
    return fn(*args, **newargs)
  File "apps/frappe/frappe/utils/typing_validations.py", line 31, in wrapper
    return func(*args, **kwargs)
  File "apps/frappe/frappe/desk/form/save.py", line 57, in cancel
    doc.cancel()
  File "apps/frappe/frappe/utils/typing_validations.py", line 31, in wrapper
    return func(*args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1053, in cancel
    return self._cancel()
  File "apps/frappe/frappe/model/document.py", line 1036, in _cancel
    return self.save()
  File "apps/frappe/frappe/model/document.py", line 337, in save
    return self._save(*args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 390, in _save
    self.run_post_save_methods()
  File "apps/frappe/frappe/model/document.py", line 1133, in run_post_save_methods
    self.run_method("on_cancel")
  File "apps/frappe/frappe/model/document.py", line 962, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1322, in composer
    return composed(self, method, *args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1304, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "apps/frappe/frappe/model/document.py", line 959, in fn
    return method_object(*args, **kwargs)
  File "apps/erpnext/erpnext/accounts/doctype/sales_invoice/sales_invoice.py", line 545, in on_cancel
    self.update_prevdoc_status()
  File "apps/erpnext/erpnext/controllers/status_updater.py", line 165, in update_prevdoc_status
    self.validate_qty()
  File "apps/erpnext/erpnext/controllers/status_updater.py", 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/frappe.desk.form.save.cancel",
	"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