Im trying get values of Purchase Invoice doctype and set them to my custom doctype ‘Titulos’ , but im getting some error when try do a event…
(I tried format the code but this is not working…)
Error when try save(it’s the event to call a function) document:
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 exactly 5 arguments (4 given)
PY:
@frappe.whitelist() def make_titulo(due_date, bill_no, posting_date, supplier_name, company): 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.empresa = company titulo.save() 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} }); console.log(frm.doc.due_date, frm.doc.bill_no, frm.doc.posting_date, frm.doc.supplier_name, frm.doc.company) }); });
Console.log returned:
2017-09-23(due_date) teste123(bill_no) 2017-07-05(posting_date) Broto Legal(supplier_name) Feijuca Brasil(company)