Gaurav | b30a9b1 | 2019-03-01 12:33:19 +0530 | [diff] [blame] | 1 | erpnext.setup_e_invoice_button = (doctype) => { |
| 2 | frappe.ui.form.on(doctype, { |
| 3 | refresh: (frm) => { |
| 4 | if(frm.doc.docstatus == 1) { |
| 5 | frm.add_custom_button('Generate E-Invoice', () => { |
Rohit Waghchaure | 1b7059b | 2019-03-12 17:44:29 +0530 | [diff] [blame] | 6 | frm.call({ |
| 7 | method: "erpnext.regional.italy.utils.generate_single_invoice", |
| 8 | args: { |
| 9 | docname: frm.doc.name |
| 10 | }, |
| 11 | callback: function(r) { |
| 12 | frm.reload_doc(); |
| 13 | if(r.message) { |
Sagar Vora | ba76f87 | 2021-03-29 20:18:45 +0530 | [diff] [blame] | 14 | open_url_post(frappe.request.url, { |
| 15 | cmd: 'frappe.core.doctype.file.file.download_file', |
| 16 | file_url: r.message |
| 17 | }); |
Rohit Waghchaure | 1b7059b | 2019-03-12 17:44:29 +0530 | [diff] [blame] | 18 | } |
| 19 | } |
| 20 | }); |
Gaurav | b30a9b1 | 2019-03-01 12:33:19 +0530 | [diff] [blame] | 21 | }); |
| 22 | } |
| 23 | } |
| 24 | }); |
| 25 | }; |