Duplicate current document on submit

Hello, is there any way for me to duplicate (like a new entry) the current sales invoice document using python server side scripting with all of its data and be able to modify some of it on_submit? For context it’s like a sales invoice document but with only the taxes so I can print it seperately.

Thank you.

Hi @iaiaian1,

It’s possible to achieve this using a server-side script, but why would you want to do it that way? I recommend that if you only need it for printing purposes, you should create a custom print format and incorporate the logic you need into it.

Thank You!

You can achieve it using copy_doc(). To refer more Document API

sales_invoice = frappe.get_doc(“Sales Invoice”, invoice_name)
new_sales_invoice = frappe.copy_doc(sales_invoice)
Change needed details using new_sales_invoice


1 Like

This is not on the documentation but might be the right answer. Thanks.

1 Like