Hello, I want to create new document for doctype on validate another doctype. Please see attached screenshot In which I am validating Library Transaction doctype but I want to insert a new Article while validating LIbrary Transaction.
PFA
Thanks
Please let me know if I am doing anything wrong.
But still I am not able to insert new doc.
Please refer to the following link and see what you missed.
https://frappeframework.staging.frappe.cloud/docs/user/en/api/document
You can also run degubber to verify what happens when LibraryTransaction validated
Or for a quick check just add
print(“Validate”)
frappe.msgprint(“Validate”)
To see if validate is being triggered
yes It is triggered the validate method also executed the insert method but new entry was not made in Article Doctype
Try restarting the bench and clear cache.
I have restarted as well as cleared the cache but no luck.
rahy
July 11, 2020, 3:16pm
8
try to use doc.insert(ignore_permissions=True)
I just figured out what I was missing.
I had to commit using frappe.db.commit() before calling insert method.
!!SOLVED!!
rahy
July 13, 2020, 4:23pm
10
Can you or anyone explain why have to use frappe.db.commit()?
Because I only use doc.insert(ignore_permissions=True) and it works fine.
Or is it may be because I insert the doc from webform (code in doctype_name.py)?