Hello, I need to create a new button on toolbar… So I do these:
frm.add_custom_button(__('test Button'), function () {
console.log( 'test') ;
});
But instead of console.log
I need to execute a def function inside my doctype.py file… how can i do that?
regards
Have you tried frappe.call function?
Here’s an example:
I tried but not work for me… probablybecause I`m not using correctly…
In my doctype.py i have these:
file: contaareceber.py
def btn_run_pgto(self):
frappe.msgprint("Im here")
file: contaareceber.js
if (!doc.__islocal && doc.status === 'Aberto') {
cur_frm.add_custom_button('Efetuar Baixa', function () {
frappe.confirm('Deseja realmente efetuar a Baixa de Registro?',
function () {
frappe.call({
"method": "frappe.client.get",
args: {
doctype: "Conta a Receber",
name: "btn_run_pgto"
},
callback: function (data) {
frappe.show_alert('Baixa Efetuada com Sucesso');
}
})
},
function () {
window.close();
}
)
}).addClass("btn-primary");
}
Running the button, returns:
Conta a Receber btn_run_pgto not found
What I missing here?
Thanks!
found the solution
frappe.call({
doc: doc,
method: "btn_run_pgto",
callback: function (data) {
frappe.show_alert('Baixa Efetuada com Sucesso');
}
})
1 Like