Error while submitting a Purchase Receipt

Hello All,

I think this is a bug.
I have a frappe dev container running:

erpnext 16.13.3 version-16 (a1c43ae)
frappe 17.x.x-develop develop (93bec95)

I create a "Purchase Receipt” and save it.

When I try to Submit the Purchase Receipt I get this message and error in the console.

MESSAGE: “Cannot change docstatus of non submittable doctype Stock Ledger Entry”

ERROR:

Traceback (most recent call last):
  File "apps/frappe/frappe/app.py", line 121, in application
    response = frappe.api.handle(request)
  File "apps/frappe/frappe/api/__init__.py", line 63, in handle
    data = endpoint(**arguments)
  File "apps/frappe/frappe/api/v1.py", line 40, in handle_rpc_call
    return frappe.handler.handle()
           ~~~~~~~~~~~~~~~~~~~~~^^
  File "apps/frappe/frappe/handler.py", line 54, in handle
    data = execute_cmd(cmd)
  File "apps/frappe/frappe/handler.py", line 87, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
           ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/__init__.py", line 1131, in call
    return fn(*args, **newargs)
  File "apps/frappe/frappe/utils/typing_validations.py", line 49, in wrapper
    return func(*args, **kwargs)
  File "apps/frappe/frappe/desk/form/save.py", line 41, in savedocs
    doc.submit()
    ~~~~~~~~~~^^
  File "apps/frappe/frappe/utils/typing_validations.py", line 49, in wrapper
    return func(*args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1410, in submit
    return self._submit()
           ~~~~~~~~~~~~^^
  File "apps/frappe/frappe/model/document.py", line 1391, in _submit
    return self.save()
           ~~~~~~~~~^^
  File "apps/frappe/frappe/model/document.py", line 518, in save
    return self._save(*args, **kwargs)
           ~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/document.py", line 572, in _save
    self.run_post_save_methods()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "apps/frappe/frappe/model/document.py", line 1518, in run_post_save_methods
    self.run_method("on_submit")
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/document.py", line 1321, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1718, in composer
    return composed(self, method, *args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1696, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
                              ~~^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/document.py", line 1318, in fn
    return method_object(*args, **kwargs)
  File "apps/erpnext/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py", line 402, in on_submit
    self.update_stock_ledger()
    ~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "apps/erpnext/erpnext/controllers/buying_controller.py", line 874, in update_stock_ledger
    self.make_sl_entries(
    ~~~~~~~~~~~~~~~~~~~~^
    	sl_entries,
     ^^^^^^^^^^^
    	allow_negative_stock=allow_negative_stock,
     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    	via_landed_cost_voucher=via_landed_cost_voucher,
     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "apps/erpnext/erpnext/controllers/stock_controller.py", line 1236, in make_sl_entries
    make_sl_entries(sl_entries, allow_negative_stock, via_landed_cost_voucher)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/erpnext/erpnext/stock/stock_ledger.py", line 98, in make_sl_entries
    sle_doc = make_entry(sle, allow_negative_stock, via_landed_cost_voucher)
  File "apps/erpnext/erpnext/stock/stock_ledger.py", line 205, in make_entry
    sle.submit()
    ~~~~~~~~~~^^
  File "apps/frappe/frappe/utils/typing_validations.py", line 49, in wrapper
    return func(*args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1410, in submit
    return self._submit()
           ~~~~~~~~~~~~^^
  File "apps/frappe/frappe/model/document.py", line 1391, in _submit
    return self.save()
           ~~~~~~~~~^^
  File "apps/frappe/frappe/model/document.py", line 518, in save
    return self._save(*args, **kwargs)
           ~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/document.py", line 540, in _save
    return self.insert()
           ~~~~~~~~~~~^^
  File "apps/frappe/frappe/model/document.py", line 439, in insert
    self.check_if_latest()
    ~~~~~~~~~~~~~~~~~~~~^^
  File "apps/frappe/frappe/model/document.py", line 1030, in check_if_latest
    self.check_docstatus_transition(0)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
  File "apps/frappe/frappe/model/document.py", line 1063, in check_docstatus_transition
    frappe.throw(
    ~~~~~~~~~~~~^
    	_("Cannot change docstatus of non submittable doctype {0}").format(self.doctype),
     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    	frappe.DocstatusTransitionError,
     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "apps/frappe/frappe/utils/messages.py", line 159, in throw
    msgprint(
    ~~~~~~~~^
    	msg,
     ^^^^
    ...<7 lines>...
    	allow_dangerous_html=allow_dangerous_html,
     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "apps/frappe/frappe/utils/messages.py", line 118, in msgprint
    _raise_exception()
    ~~~~~~~~~~~~~~~~^^
  File "apps/frappe/frappe/utils/messages.py", line 59, in _raise_exception
    raise exc
frappe.exceptions.DocstatusTransitionError: Cannot change docstatus of non submittable doctype Stock Ledger Entry

Your framework is on v17 (develop) while ERPNext is on v16 so this is expected. Not a bug. Move frappe to v16 and it will work.