Stock ledger entry from BoM automatic submit

Good morning,

from a custom module, i generate stock entries for a BoM. These are are available as “Stock Entry” but not submitted so not converted to stock ledger entries. I like to do that automatically but did not find an included way. My idea is to use a scheduled task using the stock-entry on_submit function.
I have actually two questions. one general and one specific problem:

  1. is that the right approach
  2. the stock entry instance expects a “stock_controller” not a stock item as “self” how can i implement in a proper way that from a custom script residing in a custom modules tasks script.py
    Thanks again to anyone who can give me a hint.
    Greets

Try:

stock_entry = frappe.get_doc("Stock Entry", stock_entry_name)
stock_entry.submit()