From acf83791abf854ba183f303756a9dd05fdf313a6 Mon Sep 17 00:00:00 2001 From: Saurabh Date: Sun, 24 Feb 2019 08:57:16 +0530 Subject: [PATCH] fix: file api --- erpnext/regional/italy/utils.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/erpnext/regional/italy/utils.py b/erpnext/regional/italy/utils.py index 421994c398f..85d0b4fc2c8 100644 --- a/erpnext/regional/italy/utils.py +++ b/erpnext/regional/italy/utils.py @@ -4,7 +4,7 @@ import frappe, json, os from frappe.utils import flt, cstr from erpnext.controllers.taxes_and_totals import get_itemised_tax from frappe import _ -from frappe.utils.file_manager import save_file, remove_file +from frappe.core.doctype.file.file import remove_file from frappe.desk.form.load import get_attachments from erpnext.regional.italy import state_codes @@ -248,7 +248,16 @@ def prepare_and_attach_invoice(doc): invoice_xml = frappe.render_template('erpnext/regional/italy/e-invoice.xml', context={"doc": invoice}, is_path=True) xml_filename = progressive_name + ".xml" - save_file(xml_filename, invoice_xml, dt=doc.doctype, dn=doc.name, is_private=True) + + _file = frappe.get_doc({ + "doctype": "File", + "file_name": xml_filename, + "attached_to_doctype": doc.doctype, + "attached_to_name": doc.name, + "is_private": True, + "content": invoice_xml + }) + _file.save() #Delete e-invoice attachment on cancel. def sales_invoice_on_cancel(doc, method):