How to run a batch task

Hi, everyone

We got some error data in GL Entry which are caused by our customization on journal_voucher.py. Now we fixed the problem in code, but we need cancel and resubmit the error data to get the right data in GL Entry. So does anyone know if it is possible to run a batch task to do cancel and submit Journal Voucher sheet on background problem.

What I’m thinking is writing a sql function to do it, but cancel and submit logic is very complicated, so I’ll be very appreciated if anyone has any other ideas.

@Jasmine write a patch. Refrain from writing sql functions as it wont check for the validations etc
Check this post might help. How to apply a patch in custom app?

@Jasmine there is no repost function out of the box.

What you can do is:

  1. delete all the GL related to those JVs.
  2. Re-create the GL entries using a script
je = frappe.get_doc("Journal Entry", d)
je.make_gl_entries()

Thank you for your reply. I’ll do research abut how to write a patch.