Skip to content

Commit

Permalink
Merge pull request #41708 from Mutantpenguin/patch-1
Browse files Browse the repository at this point in the history
refactor: use doctype File directly instead of save_file from file_manager.py
  • Loading branch information
ruthra-kumar authored Aug 6, 2024
2 parents 113362e + 0ba4bff commit 34ad9d3
Showing 1 changed file with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from frappe.model.document import Document
from frappe.utils import flt, get_datetime_str, today
from frappe.utils.data import format_datetime
from frappe.utils.file_manager import save_file

import erpnext

Expand Down Expand Up @@ -101,16 +100,15 @@ def prepare_data_for_import(self, file_content, file_name, encoded_content):
self.file_count += 1
if pi_name:
self.purchase_invoices_count += 1
save_file(
file_name,
encoded_content,
"Purchase Invoice",
pi_name,
folder=None,
decode=False,
is_private=0,
df=None,
)

file_doc = frappe.new_doc("File")
file_doc.file_name = file_name
file_doc.attached_to_doctype = "Purchase Invoice"
file_doc.attached_to_name = pi_name
file_doc.content = encoded_content
file_doc.decode = False
file_doc.is_private = False
file_doc.insert(ignore_permissions=True)

def prepare_items_for_invoice(self, file_content, invoices_args):
qty = 1
Expand Down

0 comments on commit 34ad9d3

Please sign in to comment.