Im trying do a call with ajax but this is not working at all…
PY:
@frappe.whitelist()
def make_titulo(due_date, bill_no, posting_date, supplier_name, purchase_invoice, bill_date, company=None):
titulo = frappe.new_doc("Titulos")
titulo.naming_series = "TIT-A-PAGAR-"
titulo.tipo_de_parte = "Supplier"
titulo.tipo_documento = "Purchase Invoice"
titulo.data_vencimento = due_date
titulo.bill_no = bill_no
titulo.data_postagem = posting_date
titulo.parte = supplier_name
titulo.documento = purchase_invoice
titulo.data_emissao = bill_date
titulo.empresa = company
titulo.save()
frappe.db.commit()
return titulo.name
JS:
frappe.ui.form.on("Purchase Invoice", "validate", function(frm) {
$.each(frm.doc.parcelas || [], function(i, d) {
// Create titulo
frappe.call({
method: "erpnext.accounts.utils.make_titulo",
args: {
due_date: frm.doc.due_date,
bill_no: frm.doc.bill_no,
posting_date: frm.doc.posting_date,
supplier_name: frm.doc.supplier_name,
purchase_invoice: frm.doc.purchase_invoice,
bill_date: frm.doc.bill_date,
company: frm.doc.company,
},
callback: function(r){
r.message
}
});
});
});
**Error:**
`Traceback (most recent call last):
File "/home/frappe/frappe-bench/apps/frappe/frappe/app.py", line 56, in application
response = frappe.handler.handle()
File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 21, in handle
data = execute_cmd(cmd)
File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 52, in execute_cmd
return frappe.call(method, **frappe.form_dict)
File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 914, in call
return fn(*args, **newargs)
TypeError: make_titulo() takes at least 4 arguments (4 given)
edit: format