Merge pull request #16761 from saurabh6790/regional_fix

fix: file api
This commit is contained in:
Saurabh 2019-02-26 13:59:10 +05:30 committed by GitHub
commit f32bae151f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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):