So I created a Server Script as suggested by @Pawan.
Script Type : DocType Event
Reference Document Type : Sales Order
DocType Event : Before Save (Submitted Document)
and wrote the following code as per examples give in the previous post.
from erpnext.selling.doctype.sales_order.sales_order import make_sales_invoice
current_date = doc.transaction_date;
so = doc;
if so.docstatus==1 and not so.per_billed:
si = make_sales_invoice(so)
si.doc.posting_date = current_date
Unfortunately, I get the following error when a Sales Order is updated.
ImportError: __import__ not found
It seems that I am very close to the solution. I would be obliged if anyone (especially @Pawan) can help to fix that probelm.
@Pawan : You mentioned that this is available using server scripts. How would one do it then, if the erpnext functions are not available. Sales Order for example uses from frappe.model.mapper import get_mapped_doc to create a sales invoice (inmake_sales_invoice()). From what I can see, this function can not be called from a server script.
Thanks Pawan. I will try.
(Concerning the tagging: Not sure what the purpose of the tags are if not to address specific people? Feel free to not answer if tagged (as you said, it’s a voluntary forum). If tagging should not be used, this feature should be disabled in my opinion or a clearer guideline should be provided in https://discuss.erpnext.com/faq. Any clarification in this regard is appreciated. Maybe I just didn’t understand so far what the purpose of the tags are…)