// Copyright (c) 2020, Studio Infinity and contributors // For license information, please see license.txt function process_invoice_file(frm) { return frappe.call({ method: "process_invoice_file", doc: frm.doc, callback: function(r, rt) { frm.refresh_field("lines"); frm.refresh_fields(); } }); } frappe.ui.form.on('JW Import', { // refresh: function(frm) { // } setup: function(frm) { let lff_field = frm.fields_dict.load_from_file; lff_field.on_upload_complete = function(attachment) { Object.getPrototypeOf(this).on_upload_complete.call(this, attachment); this.frm.doc.load_from_file = attachment.file_url; process_invoice_file(this.frm); }; }, load_from_file: function(frm) { if (!frm.doc.load_from_file) { frm.clear_table('lines'); frm.refresh_field('lines'); } } });