fix: E-way bill fix in Delivery Note

This commit is contained in:
Deepesh Garg 2020-04-27 10:50:59 +05:30
parent 00ea59b447
commit 4eecc65cff

View File

@ -3,21 +3,28 @@
erpnext.setup_auto_gst_taxation('Delivery Note');
frappe.ui.form.on('Delivery Note', {
refresh: function(frm) {
if(frm.doc.docstatus == 1 && !frm.is_dirty() && !frm.doc.ewaybill) {
refresh: function(frm) {
if(frm.doc.docstatus == 1 && !frm.is_dirty() && !frm.doc.ewaybill) {
frm.add_custom_button('E-Way Bill JSON', () => {
var w = window.open(
frappe.urllib.get_full_url(
"/api/method/erpnext.regional.india.utils.generate_ewb_json?"
+ "dt=" + encodeURIComponent(frm.doc.doctype)
+ "&dn=" + encodeURIComponent(frm.doc.name)
)
);
if (!w) {
frappe.msgprint(__("Please enable pop-ups")); return;
}
frappe.call({
method: 'erpnext.regional.india.utils.generate_ewb_json',
args: {
'dt': frm.doc.doctype,
'dn': [frm.doc.name]
},
callback: function(r) {
if (r.message) {
const args = {
cmd: 'erpnext.regional.india.utils.download_ewb_json',
data: r.message,
docname: frm.doc.name
};
open_url_post(frappe.request.url, args);
}
}
});
}, __("Create"));
}
}
}
})