fix: Move E-Way bill button under create

This commit is contained in:
Deepesh Garg 2020-02-02 21:25:58 +05:30
parent ffa74ad5c1
commit cce3ac9f79
3 changed files with 9 additions and 9 deletions

View File

@ -25,7 +25,7 @@ frappe.ui.form.on("Sales Invoice", {
if(frm.doc.docstatus == 1 && !frm.is_dirty() if(frm.doc.docstatus == 1 && !frm.is_dirty()
&& !frm.doc.is_return && !frm.doc.ewaybill) { && !frm.doc.is_return && !frm.doc.ewaybill) {
frm.add_custom_button('e-Way Bill JSON', () => { frm.add_custom_button('E-Way Bill JSON', () => {
var w = window.open( var w = window.open(
frappe.urllib.get_full_url( frappe.urllib.get_full_url(
"/api/method/erpnext.regional.india.utils.generate_ewb_json?" "/api/method/erpnext.regional.india.utils.generate_ewb_json?"
@ -36,7 +36,7 @@ frappe.ui.form.on("Sales Invoice", {
if (!w) { if (!w) {
frappe.msgprint(__("Please enable pop-ups")); return; frappe.msgprint(__("Please enable pop-ups")); return;
} }
}, __("Make")); }, __("Create"));
} }
} }

View File

@ -12,7 +12,7 @@ frappe.listview_settings['Sales Invoice'].onload = function (doclist) {
for (let doc of selected_docs) { for (let doc of selected_docs) {
if (doc.docstatus !== 1) { if (doc.docstatus !== 1) {
frappe.throw(__("e-Way Bill JSON can only be generated from a submitted document")); frappe.throw(__("E-Way Bill JSON can only be generated from a submitted document"));
} }
} }
@ -29,5 +29,5 @@ frappe.listview_settings['Sales Invoice'].onload = function (doclist) {
}; };
doclist.page.add_actions_menu_item(__('Generate e-Way Bill JSON'), action, false); doclist.page.add_actions_menu_item(__('Generate E-Way Bill JSON'), action, false);
}; };

View File

@ -358,7 +358,7 @@ def calculate_hra_exemption_for_period(doc):
def get_ewb_data(dt, dn): def get_ewb_data(dt, dn):
if dt != 'Sales Invoice': if dt != 'Sales Invoice':
frappe.throw(_('e-Way Bill JSON can only be generated from Sales Invoice')) frappe.throw(_('E-Way Bill JSON can only be generated from Sales Invoice'))
dn = dn.split(',') dn = dn.split(',')
@ -381,7 +381,7 @@ def get_ewb_data(dt, dn):
elif doc.gst_category in ['Overseas', 'Deemed Export']: elif doc.gst_category in ['Overseas', 'Deemed Export']:
data.subSupplyType = 3 data.subSupplyType = 3
else: else:
frappe.throw(_('Unsupported GST Category for e-Way Bill JSON generation')) frappe.throw(_('Unsupported GST Category for E-Way Bill JSON generation'))
data.docType = 'INV' data.docType = 'INV'
data.docDate = frappe.utils.formatdate(doc.posting_date, 'dd/mm/yyyy') data.docDate = frappe.utils.formatdate(doc.posting_date, 'dd/mm/yyyy')
@ -537,10 +537,10 @@ def get_item_list(data, doc):
def validate_sales_invoice(doc): def validate_sales_invoice(doc):
if doc.docstatus != 1: if doc.docstatus != 1:
frappe.throw(_('e-Way Bill JSON can only be generated from submitted document')) frappe.throw(_('E-Way Bill JSON can only be generated from submitted document'))
if doc.is_return: if doc.is_return:
frappe.throw(_('e-Way Bill JSON cannot be generated for Sales Return as of now')) frappe.throw(_('E-Way Bill JSON cannot be generated for Sales Return as of now'))
if doc.ewaybill: if doc.ewaybill:
frappe.throw(_('e-Way Bill already exists for this document')) frappe.throw(_('e-Way Bill already exists for this document'))
@ -550,7 +550,7 @@ def validate_sales_invoice(doc):
for fieldname in reqd_fields: for fieldname in reqd_fields:
if not doc.get(fieldname): if not doc.get(fieldname):
frappe.throw(_('{} is required to generate e-Way Bill JSON').format( frappe.throw(_('{} is required to generate E-Way Bill JSON').format(
doc.meta.get_label(fieldname) doc.meta.get_label(fieldname)
)) ))