Open the file erpnext.patches.v8_7.add_more_gst_fields, and add this line to the top of execute function
frappe.reload_doc('accounts', 'doctype', 'payment_terms_template')
and run the patch again.
If this solution works, please send a PR with your changes