brotherton-erpnext/erpnext/regional/italy/sales_invoice.js
2019-03-27 15:33:47 +05:30

31 lines
748 B
JavaScript

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', () => {
frm.call({
method: "erpnext.regional.italy.utils.generate_single_invoice",
args: {
docname: frm.doc.name
},
callback: function(r) {
frm.reload_doc();
if(r.message) {
var w = window.open(
frappe.urllib.get_full_url(
"/api/method/erpnext.regional.italy.utils.download_e_invoice_file?"
+ "file_name=" + r.message
)
)
if (!w) {
frappe.msgprint(__("Please enable pop-ups")); return;
}
}
}
});
});
}
}
});
};