2019-03-01 07:03:19 +00:00
|
|
|
erpnext.setup_e_invoice_button = (doctype) => {
|
|
|
|
frappe.ui.form.on(doctype, {
|
|
|
|
refresh: (frm) => {
|
|
|
|
if(frm.doc.docstatus == 1) {
|
|
|
|
frm.add_custom_button('Generate E-Invoice', () => {
|
2019-03-12 12:14:29 +00:00
|
|
|
frm.call({
|
|
|
|
method: "erpnext.regional.italy.utils.generate_single_invoice",
|
|
|
|
args: {
|
|
|
|
docname: frm.doc.name
|
|
|
|
},
|
|
|
|
callback: function(r) {
|
|
|
|
frm.reload_doc();
|
|
|
|
if(r.message) {
|
2021-03-29 14:48:45 +00:00
|
|
|
open_url_post(frappe.request.url, {
|
|
|
|
cmd: 'frappe.core.doctype.file.file.download_file',
|
|
|
|
file_url: r.message
|
|
|
|
});
|
2019-03-12 12:14:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2019-03-01 07:03:19 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|