Custom Field Button

287 views
Skip to first unread message

Luis Fernandes

unread,
Sep 17, 2014, 8:22:15 AM9/17/14
to erpnext-dev...@googlegroups.com
Ok. fixtures "Custom Filed" works!

But now i need to know where i put my handler for the custom field of type ('Button').

I try to put it in custom script for the Customer doctype, some thing like this:

frappe.ui.form.on("Customer", "validate_vat", function(ev){ <-- validate_vat is the field name of the button
     console.log("button was clicked! ", ev.doc.vat_or_nif);<-- that ok, but i feel that is not the wright way.
     //here i will call, of course, a whitelist method... 
}); 

I would like soem thins like cur_frm.on("click", "validate_vat", func);

I realize that when i click the button i get this: 


Traceback (innermost last):
File "/vagrant/frappe-bench/apps/frappe/frappe/app.py", line 49, in application
response = frappe.handler.handle()
File "/vagrant/frappe-bench/apps/frappe/frappe/handler.py", line 66, in handle
execute_cmd(cmd)
File "/vagrant/frappe-bench/apps/frappe/frappe/handler.py", line 89, in execute_cmd
ret = frappe.call(method, **frappe.form_dict)
File "/vagrant/frappe-bench/apps/frappe/frappe/__init__.py", line 531, in call
return fn(*args, **newargs)
TypeError: runserverobj() takes at least 1 argument (1 given)

return fn(*args, **newargs) <-- where i put my function?? What is he calling??

 
What is the wright way?



Thanks.

Luis Fernandes

unread,
Sep 17, 2014, 9:18:52 AM9/17/14
to erpnext-dev...@googlegroups.com
I think i know the answer!!!

I just need to put this in custom script:

cur_frm.cscript["validate_vat"] = function(doc, dt, name){
  console.log("onclick ", name);
}

Where validate_vat is button field name.

I think this is the right way...

Thanks anyway.
Reply all
Reply to author
Forward
0 new messages