Custom Field Button

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.



Note:

 

If you are posting an issue,

 

  1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
  2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  4. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.

     

    End of Note



    You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.

    To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/41f277bd-5196-413f-9ae8-c7efd1bf3f92%40googlegroups.com.

    For more options, visit https://groups.google.com/d/optout.
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.

Quarta-feira, 17 de Setembro de 2014 13:22:15 UTC+1, Luis Fernandes escreveu:
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.



Note:

 

If you are posting an issue,

 

  1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
  2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  4. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.

     

    End of Note



    You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.

    To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/f306c337-3c65-4973-9944-3a7f98720878%40googlegroups.com.

    For more options, visit https://groups.google.com/d/optout.