Get and Delete doctype

I’m trying get an doctype and delete it, but nothing is happening. I have an child table in Purchase Invoice form, and I’m getting ‘serie_parcela’ docfield value for each row. Each Titulo form has this value too in ‘ref_parcela’ docfield, so i use this to do a get_doc and delete it.


//Deleting Titulos on Purchase Invoice cancel 
frappe.ui.form.on("Purchase Invoice", "on_cancel", function(frm) {	
	$.each(frm.doc.parcelas || [], function (i, d) {{
			method: "financeiro.financeiro.doctype.titulos.titulos.delete_titulo",
			args: {
				serie_parcela: d.serie_parcela,
      callback: function(r){


def delete_titulo(serie_parcela):
    titulos = frappe.get_doc({
        "doctype" : "Titulos",
        "ref_parcela" : serie_parcela
    delete = frappe.delete_doc(titulos)
    return delete

You aren’t using delete doc correctly. You just need to pass the doctype and the docname, not the whole doc.

def delete_titulo(serie_parcela):
    delete = frappe.delete_doc("Titulos",serie_parcela)
    return delete

You could also do this directly through javascript: