Autogenerating purchase invoices from subscription if no default company set

In our ERPNext instance we experimented with not setting a default company and this caused subscriptions to fail with this error:

Traceback with variables (most recent call last):
  File "apps/erpnext/erpnext/accounts/doctype/subscription/subscription.py", line 722, in process
    subscription.process()
      data = {'name': 'ACC-SUB-2024-00003'}
      subscription = <Subscription: ACC-SUB-2024-00003>
  File "apps/erpnext/erpnext/accounts/doctype/subscription/subscription.py", line 513, in process
    self.process_for_active()
      self = <Subscription: ACC-SUB-2024-00003>
  File "apps/erpnext/erpnext/accounts/doctype/subscription/subscription.py", line 567, in process_for_active
    self.generate_invoice(prorate)
      self = <Subscription: ACC-SUB-2024-00003>
      prorate = 1
  File "apps/erpnext/erpnext/accounts/doctype/subscription/subscription.py", line 332, in generate_invoice
    invoice = self.create_invoice(prorate)
      self = <Subscription: ACC-SUB-2024-00003>
      prorate = 1
      doctype = 'Purchase Invoice'
  File "apps/erpnext/erpnext/accounts/doctype/subscription/subscription.py", line 351, in create_invoice
    frappe.throw(
      self = <Subscription: ACC-SUB-2024-00003>
      prorate = 1
      doctype = 'Purchase Invoice'
      invoice = <PurchaseInvoice: unsaved>
      company = ''
  File "apps/frappe/frappe/__init__.py", line 536, in throw
    msgprint(
      msg = 'Company is mandatory was generating invoice. Please set default company in Global Defaults'
      exc = <class 'frappe.exceptions.ValidationError'>
      title = None
      is_minimizable = False
      wide = False
      as_list = False
  File "apps/frappe/frappe/__init__.py", line 504, in msgprint
    _raise_exception()
      title = None
      as_table = False
      as_list = False
      indicator = 'red'
      alert = False
      primary_action = None
      is_minimizable = False
      wide = False
      realtime = False
      sys = <module 'sys' (built-in)>
      out = {'message': 'Company is mandatory was generating invoice. Please set default company in Global Defaults', 'title': 'Message', 'indicator': 'red', 'raise_exception': 1}
      _raise_exception = <function msgprint.<locals>._raise_exception at 0x7f4d24920a60>
      _strip_html_tags = <functools._lru_cache_wrapper object at 0x7f4d211a89e0>
      inspect = <module 'inspect' from '/usr/lib/python3.10/inspect.py'>
      msg = 'Company is mandatory was generating invoice. Please set default company in Global Defaults'
      raise_exception = <class 'frappe.exceptions.ValidationError'>
      strip_html_tags = <function strip_html_tags at 0x7f4d24cb3640>
  File "apps/frappe/frappe/__init__.py", line 450, in _raise_exception
    raise raise_exception(msg)
      inspect = <module 'inspect' from '/usr/lib/python3.10/inspect.py'>
      msg = 'Company is mandatory was generating invoice. Please set default company in Global Defaults'
      raise_exception = <class 'frappe.exceptions.ValidationError'>
frappe.exceptions.ValidationError: Company is mandatory was generating invoice. Please set default company in Global Defaults

Is there any way this can be made to work if a global default company is not set? For example with a default company set via user permissions?

You should go this setting: